00001 /* ThemeMetric - Theme specific data. */ 00002 00003 #ifndef THEME_METRIC_H 00004 #define THEME_METRIC_H 00005 00006 #include "ThemeManager.h" 00007 00008 class IThemeMetric 00009 { 00010 public: 00011 virtual ~IThemeMetric() { } 00012 virtual void Read() = 0; 00013 }; 00014 00015 template <class T> 00016 class ThemeMetric : public IThemeMetric 00017 { 00018 private: 00019 CString m_sGroup; 00020 CString m_sName; 00021 T m_currentValue; 00022 00023 public: 00024 ThemeMetric( const CString& sGroup, const CString& sName ): 00025 m_sGroup( sGroup ), 00026 m_sName( sName ) 00027 { 00028 m_currentValue = T(); 00029 ThemeManager::Subscribe( this ); 00030 } 00031 00032 ~ThemeMetric() 00033 { 00034 ThemeManager::Unsubscribe( this ); 00035 } 00036 00037 void ChangeGroup( const CString &sGroup ) 00038 { 00039 m_sGroup = sGroup; 00040 Read(); 00041 } 00042 00043 void Read() 00044 { 00045 THEME->GetMetric( m_sGroup, m_sName, m_currentValue ); 00046 } 00047 00048 const T& GetValue() const 00049 { 00050 return m_currentValue; 00051 } 00052 00053 operator const T& () const 00054 { 00055 return m_currentValue; 00056 } 00057 }; 00058 00059 #endif 00060 00061 /* 00062 * (c) 2001-2004 Chris Danford, Chris Gomez 00063 * All rights reserved. 00064 * 00065 * Permission is hereby granted, free of charge, to any person obtaining a 00066 * copy of this software and associated documentation files (the 00067 * "Software"), to deal in the Software without restriction, including 00068 * without limitation the rights to use, copy, modify, merge, publish, 00069 * distribute, and/or sell copies of the Software, and to permit persons to 00070 * whom the Software is furnished to do so, provided that the above 00071 * copyright notice(s) and this permission notice appear in all copies of 00072 * the Software and that both the above copyright notice(s) and this 00073 * permission notice appear in supporting documentation. 00074 * 00075 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00076 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00077 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00078 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00079 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00080 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00081 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00082 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00083 * PERFORMANCE OF THIS SOFTWARE. 00084 */