allow initializing ThemeMetric outside the ctor

This commit is contained in:
Glenn Maynard
2005-02-02 04:48:25 +00:00
parent df00267cf7
commit 6ce6500611
+15 -1
View File
@@ -21,7 +21,11 @@ private:
T m_currentValue; T m_currentValue;
public: public:
ThemeMetric( const CString& sGroup, const CString& sName ): /* Initializing with no group and name is allowed; if you do this, you must
* call Load() to set them. This is done to allow initializing cached metrics
* in one place for classes that don't receive their m_sName in the constructor
* (everything except screens). */
ThemeMetric( const CString& sGroup = "", const CString& sName = "" ):
m_sGroup( sGroup ), m_sGroup( sGroup ),
m_sName( sName ) m_sName( sName )
{ {
@@ -34,6 +38,13 @@ public:
ThemeManager::Unsubscribe( this ); ThemeManager::Unsubscribe( this );
} }
void Load( const CString &sGroup, const CString& sName )
{
m_sGroup = sGroup;
m_sName = sName;
Read();
}
void ChangeGroup( const CString &sGroup ) void ChangeGroup( const CString &sGroup )
{ {
m_sGroup = sGroup; m_sGroup = sGroup;
@@ -42,11 +53,14 @@ public:
void Read() void Read()
{ {
if( m_sName != "" )
THEME->GetMetric( m_sGroup, m_sName, m_currentValue ); THEME->GetMetric( m_sGroup, m_sName, m_currentValue );
} }
const T& GetValue() const const T& GetValue() const
{ {
ASSERT( m_sName != "" );
return m_currentValue; return m_currentValue;
} }