move more common stuff out of the template class, so g_pvpSubscribers is

more useful
This commit is contained in:
Glenn Maynard
2004-12-07 01:44:17 +00:00
parent c37a82ed40
commit ba929b8e71
2 changed files with 51 additions and 31 deletions
+32 -9
View File
@@ -10,31 +10,54 @@ static const CString PrefsGroupNames[NUM_PREFS_GROUPS] = {
};
XToString( PrefsGroup );
void SubscribePreference( IPreference *p )
IPreference::IPreference( PrefsGroup PrefsGroup, const CString& sName ):
m_PrefsGroup( PrefsGroup ),
m_sName( sName )
{
PrefsManager::Subscribe( p );
PrefsManager::Subscribe( this );
}
void UnsubscribePreference( IPreference *p )
IPreference::~IPreference()
{
PrefsManager::Unsubscribe( p );
PrefsManager::Unsubscribe( this );
}
void Preference<CString>::FromString( const CString &s )
{
m_currentValue = s;
}
CString Preference<CString>::ToString() const
{
return m_currentValue;
}
#define READFROM_AND_WRITETO( type ) \
void Preference<type>::ReadFrom( const IniFile &ini ) \
void Preference<type>::FromString( const CString &s ) \
{ \
ini.GetValue( PrefsGroupToString(m_PrefsGroup), m_sName, m_currentValue ); \
::FromString( s, m_currentValue ); \
} \
void Preference<type>::WriteTo( IniFile &ini ) const \
CString Preference<type>::ToString() const \
{ \
ini.SetValue( PrefsGroupToString(m_PrefsGroup), m_sName, m_currentValue ); \
return ::ToString( m_currentValue ); \
} \
READFROM_AND_WRITETO( CString )
READFROM_AND_WRITETO( int )
READFROM_AND_WRITETO( float )
READFROM_AND_WRITETO( bool )
void IPreference::ReadFrom( const IniFile &ini )
{
CString sVal;
if( ini.GetValue( PrefsGroupToString(m_PrefsGroup), m_sName, sVal ) )
FromString( sVal );
}
void IPreference::WriteTo( IniFile &ini ) const
{
ini.SetValue( PrefsGroupToString(m_PrefsGroup), m_sName, ToString() );
}
/*
* (c) 2001-2004 Chris Danford, Chris Gomez
* All rights reserved.