SettingManager Class Reference

#include <SettingManager.h>

List of all members.

Public Types

typedef void(*) ConfigCallback (Pentagram::istring key)
 DOM_DEFAULTS = 0
 DOM_GLOBAL = 1
 DOM_GAME = 2
 DOM_CURRENT = 100
enum  Domain { DOM_DEFAULTS = 0, DOM_GLOBAL = 1, DOM_GAME = 2, DOM_CURRENT = 100 }

Public Member Functions

 SettingManager ()
 ~SettingManager ()
bool readConfigFile (std::string fname, bool readonly=false)
void write ()
bool exists (Pentagram::istring key, Domain dom=DOM_CURRENT)
bool get (Pentagram::istring key, std::string &ret, Domain dom=DOM_CURRENT)
bool get (Pentagram::istring key, int &ret, Domain dom=DOM_CURRENT)
bool get (Pentagram::istring key, bool &ret, Domain dom=DOM_CURRENT)
void set (Pentagram::istring key, std::string value, Domain dom=DOM_CURRENT)
void set (Pentagram::istring key, const char *value, Domain dom=DOM_CURRENT)
void set (Pentagram::istring key, int value, Domain dom=DOM_CURRENT)
void set (Pentagram::istring key, bool value, Domain dom=DOM_CURRENT)
void unset (Pentagram::istring key, Domain dom=DOM_CURRENT)
void setDefault (Pentagram::istring key, std::string value)
void setDefault (Pentagram::istring key, const char *value)
void setDefault (Pentagram::istring key, int value)
void setDefault (Pentagram::istring key, bool value)
void setCurrentDomain (Domain dom)
void setDomainName (Domain dom, Pentagram::istring section)
void registerCallback (Pentagram::istring key, ConfigCallback callback)
void unregisterCallback (Pentagram::istring key, ConfigCallback callback)
std::vector< Pentagram::istringlistGames ()
std::vector< Pentagram::istringlistDataKeys (Pentagram::istring section)
std::map< Pentagram::istring,
std::string > 
listDataValues (Pentagram::istring section)

Static Public Member Functions

static SettingManagerget_instance ()

Private Member Functions

bool findKeyDomain (Pentagram::istring key, Domain dom, Domain &keydom)
Pentagram::istring getConfigKey (Pentagram::istring key, Domain dom)
void callCallbacks (Pentagram::istring key)

Private Attributes

std::map< Pentagram::istring,
std::vector< ConfigCallback > > 
callbacks
std::vector< Pentagram::istringdomains
Domain currentDomain
ConfigFileManagerconffileman

Static Private Attributes

static SettingManagersettingmanager = 0


Detailed Description

Definition at line 29 of file SettingManager.h.


Member Typedef Documentation

typedef void(*) SettingManager::ConfigCallback(Pentagram::istring key)

Definition at line 89 of file SettingManager.h.


Member Enumeration Documentation

enum SettingManager::Domain

Enumerator:
DOM_DEFAULTS 
DOM_GLOBAL 
DOM_GAME 
DOM_CURRENT 

Definition at line 37 of file SettingManager.h.


Constructor & Destructor Documentation

SettingManager::SettingManager (  ) 

Definition at line 28 of file SettingManager.cpp.

References con, conffileman, DOM_GAME, domains, ConfigFileManager::get_instance(), MM_INFO, Console::Print(), ConfigFileManager::readConfigString(), and settingmanager.

SettingManager::~SettingManager (  ) 

Definition at line 42 of file SettingManager.cpp.

References con, MM_INFO, Console::Print(), and settingmanager.


Member Function Documentation

void SettingManager::callCallbacks ( Pentagram::istring  key  )  [private]

bool SettingManager::exists ( Pentagram::istring  key,
Domain  dom = DOM_CURRENT 
)

does the key exist?

Referenced by HIDManager::saveBindings().

bool SettingManager::findKeyDomain ( Pentagram::istring  key,
Domain  dom,
Domain keydom 
) [private]

bool SettingManager::get ( Pentagram::istring  key,
bool &  ret,
Domain  dom = DOM_CURRENT 
)

get value

bool SettingManager::get ( Pentagram::istring  key,
int &  ret,
Domain  dom = DOM_CURRENT 
)

get value

bool SettingManager::get ( Pentagram::istring  key,
std::string &  ret,
Domain  dom = DOM_CURRENT 
)

get value

Referenced by FontManager::addTTFOverride(), BarkGump::BarkGump(), MainActor::ConCmd_recall(), ActorAnimProcess::doSpecial(), CoreApp::getDefaultGame(), GUIApp::GraphicSysInit(), MenuGump::InitGump(), AvatarMoverProcess::jump(), CoreApp::loadConfig(), BarkGump::loadData(), GUIApp::loadGame(), FontManager::loadTTFont(), Pentagram::AudioMixer::openMidiOutput(), MenuGump::selectEntry(), CoreApp::setupGamePaths(), GameData::setupJPOverrides(), ScalerGump::SetupScalers(), GameData::setupTTFOverrides(), StartU8Process::StartU8Process(), GUIApp::startup(), GUIApp::startupGame(), and NS_TIMIDITY::Timidity_Init_Simple().

static SettingManager* SettingManager::get_instance (  )  [inline, static]

Definition at line 35 of file SettingManager.h.

References settingmanager.

Referenced by FontManager::addTTFOverride(), BarkGump::BarkGump(), ScalerGump::ChangeScaler(), MainActor::ConCmd_listmarks(), MainActor::ConCmd_mark(), MainActor::ConCmd_recall(), HIDManager::ConCmd_save(), ActorAnimProcess::doSpecial(), FontManager::FontManager(), PentagramMenuGump::InitGump(), MenuGump::InitGump(), AvatarMoverProcess::jump(), HIDManager::loadBindings(), BarkGump::loadData(), FontManager::loadTTFont(), Pentagram::AudioMixer::openMidiOutput(), RemorseGame::RemorseGame(), CreditsGump::Run(), HIDManager::saveBindings(), MenuGump::selectEntry(), GameData::setupJPOverrides(), ScalerGump::SetupScalers(), GameData::setupTTFOverrides(), StartU8Process::StartU8Process(), NS_TIMIDITY::Timidity_Init_Simple(), and U8Game::U8Game().

Pentagram::istring SettingManager::getConfigKey ( Pentagram::istring  key,
Domain  dom 
) [private]

std::vector<Pentagram::istring> SettingManager::listDataKeys ( Pentagram::istring  section  ) 

list all keys in a game data section

Parameters:
section The section to return setkeys of
Returns:
the keys. They have no guaranteed order.

Referenced by MainActor::ConCmd_listmarks().

std::map<Pentagram::istring,std::string> SettingManager::listDataValues ( Pentagram::istring  section  ) 

list all key-value pairs in the given section.

Parameters:
section The section to list
Returns:
the key-value pairs. They have no guaranteed order.

Referenced by HIDManager::loadBindings().

std::vector< istring > SettingManager::listGames (  ) 

list all games

Definition at line 195 of file SettingManager.cpp.

References conffileman, ConfigFileManager::exists(), and ConfigFileManager::listSections().

Referenced by GUIApp::ConCmd_listGames(), PentagramMenuGump::InitGump(), and CoreApp::setupGameList().

bool SettingManager::readConfigFile ( std::string  fname,
bool  readonly = false 
)

read a config file. Multiple files may be read. Order is important.

Parameters:
fname The file to read
readonly If true, don't write to this file's tree (or the file)
Returns:
true if succesful

Definition at line 49 of file SettingManager.cpp.

References conffileman, and ConfigFileManager::readConfigFile().

Referenced by CoreApp::loadConfig().

void SettingManager::registerCallback ( Pentagram::istring  key,
ConfigCallback  callback 
)

register a function to be called when the key changes

void SettingManager::set ( Pentagram::istring  key,
bool  value,
Domain  dom = DOM_CURRENT 
)

set value

void SettingManager::set ( Pentagram::istring  key,
int  value,
Domain  dom = DOM_CURRENT 
)

set value

void SettingManager::set ( Pentagram::istring  key,
const char *  value,
Domain  dom = DOM_CURRENT 
)

set value

void SettingManager::set ( Pentagram::istring  key,
std::string  value,
Domain  dom = DOM_CURRENT 
)

set value

Referenced by ScalerGump::ChangeScaler(), GUIApp::changeVideoMode(), MainActor::ConCmd_mark(), GUIApp::GraphicSysInit(), CreditsGump::Run(), and HIDManager::saveBindings().

void SettingManager::setCurrentDomain ( Domain  dom  ) 

set the current domain

Definition at line 160 of file SettingManager.cpp.

References currentDomain.

Referenced by CoreApp::killGame(), CoreApp::setupGamePaths(), and CoreApp::sysInit().

void SettingManager::setDefault ( Pentagram::istring  key,
bool  value 
)

set default value

void SettingManager::setDefault ( Pentagram::istring  key,
int  value 
)

set default value

void SettingManager::setDefault ( Pentagram::istring  key,
const char *  value 
)

set default value

void SettingManager::setDefault ( Pentagram::istring  key,
std::string  value 
)

set default value

Referenced by FontManager::FontManager(), GUIApp::GraphicSysInit(), GUIApp::loadGame(), Pentagram::AudioMixer::openMidiOutput(), RemorseGame::RemorseGame(), ScalerGump::SetupScalers(), GUIApp::startupGame(), and U8Game::U8Game().

void SettingManager::setDomainName ( Domain  dom,
Pentagram::istring  section 
)

set the configuration section for a domain

Referenced by CoreApp::setupGamePaths(), and CoreApp::sysInit().

void SettingManager::unregisterCallback ( Pentagram::istring  key,
ConfigCallback  callback 
)

unregister a callback

void SettingManager::unset ( Pentagram::istring  key,
Domain  dom = DOM_CURRENT 
)

remove key

Referenced by HIDManager::saveBindings().

void SettingManager::write (  ) 

write all (writable) config files

Definition at line 54 of file SettingManager.cpp.

References conffileman, and ConfigFileManager::write().

Referenced by MainActor::ConCmd_mark(), and HIDManager::ConCmd_save().


Member Data Documentation

std::map<Pentagram::istring, std::vector<ConfigCallback> > SettingManager::callbacks [private]

Definition at line 116 of file SettingManager.h.

ConfigFileManager* SettingManager::conffileman [private]

Definition at line 121 of file SettingManager.h.

Referenced by listGames(), readConfigFile(), SettingManager(), and write().

Domain SettingManager::currentDomain [private]

Definition at line 119 of file SettingManager.h.

Referenced by setCurrentDomain().

std::vector<Pentagram::istring> SettingManager::domains [private]

Definition at line 117 of file SettingManager.h.

Referenced by SettingManager().

SettingManager * SettingManager::settingmanager = 0 [static, private]

Definition at line 123 of file SettingManager.h.

Referenced by get_instance(), SettingManager(), and ~SettingManager().


The documentation for this class was generated from the following files:
Generated on Fri Jul 27 22:29:54 2007 for pentagram by  doxygen 1.4.7