xoreos  0.0.5
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Common::ConfigManager Class Reference

The global config manager, storing all config keys. More...

#include <configman.h>

Inheritance diagram for Common::ConfigManager:
Inheritance graph
[legend]
Collaboration diagram for Common::ConfigManager:
Collaboration graph
[legend]

Public Member Functions

 ConfigManager ()
 
 ~ConfigManager ()
 
UString getConfigFile () const
 Return the config file that's currently in use. More...
 
void setConfigFile (const UString &file="")
 Set the config file to use. More...
 
void clear ()
 Clear everything except the command line options. More...
 
void clearCommandline ()
 Clear the command line options. More...
 
bool fileExists () const
 Does the config file exist? More...
 
bool changed () const
 Was at least on setting changed? More...
 
bool load ()
 Load from the default config file. More...
 
void load (SeekableReadStream &stream)
 Load from a generic read stream. More...
 
bool save ()
 Save to the default config file. More...
 
void save (WriteStream &stream, bool clearChanged=false)
 Save to a generic write stream. More...
 
void create ()
 Create a new, empty config. More...
 
UString findGame (const UString &path)
 Find the game domain using this path. More...
 
UString createGame (const UString &path, UString target="")
 Create the game domain with this path and target. More...
 
bool hasGame (const UString &gameID)
 Does the specified game domain exist? More...
 
bool setGame (const UString &gameID="")
 Set the game domain to gameID. More...
 
bool isInGame () const
 Are we currently in a game? More...
 
bool hasKey (const UString &key) const
 
bool getKey (const UString &key, UString &value) const
 
UString getString (const UString &key) const
 
bool getBool (const UString &key) const
 
int getInt (const UString &key) const
 
double getDouble (const UString &key) const
 
UString getString (const UString &key, const UString &def) const
 
bool getBool (const UString &key, bool def) const
 
int getInt (const UString &key, int def) const
 
double getDouble (const UString &key, double def) const
 
void setKey (const UString &key, const UString &value, bool update=false)
 
void setString (const UString &key, const UString &value, bool update=false)
 
void setBool (const UString &key, bool value, bool update=false)
 
void setInt (const UString &key, int value, bool update=false)
 
void setDouble (const UString &key, double value, bool update=false)
 
void setKey (ConfigRealm realm, const UString &key, const UString &value)
 Set a config value in a specific realm. More...
 
void setString (ConfigRealm realm, const UString &key, const UString &value)
 
void setBool (ConfigRealm realm, const UString &key, bool value)
 
void setInt (ConfigRealm realm, const UString &key, int value)
 
void setDouble (ConfigRealm realm, const UString &key, double value)
 
void setDefaults ()
 Overwrite the current config with the defaults. More...
 
bool hasDefaultKey (const UString &key) const
 
UString getDefaultKey (const UString &key) const
 
UString getDefaultString (const UString &key) const
 
bool getDefaultBool (const UString &key) const
 
int getDefaultInt (const UString &key) const
 
double getDefaultDouble (const UString &key) const
 
void setCommandlineKey (const UString &key, const UString &value)
 Set a config value that came from the command line. More...
 

Private Member Functions

UString createGameID (const UString &path)
 
bool hasKey (const ConfigDomain *domain, const UString &key) const
 
bool getKey (const ConfigDomain *domain, const UString &key, UString &value) const
 
bool setKey (ConfigDomain *domain, const UString &key, const UString &value)
 

Static Private Member Functions

static UString getDefaultConfigFile ()
 

Private Attributes

UString _configFile
 The config file to use. More...
 
bool _changed
 
ScopedPtr< ConfigFile_config
 The actual config. More...
 
ScopedPtr< ConfigDomain_domainDefaultApp
 Application defaults domain. More...
 
ScopedPtr< ConfigDomain_domainDefaultGame
 Game defaults domain. More...
 
ScopedPtr< ConfigDomain_domainCommandline
 Command line domain. More...
 
ScopedPtr< ConfigDomain_domainGameTemp
 Temporary game settings domain. More...
 
ConfigDomain_domainApp
 Application domain, pointer into the config file. More...
 
ConfigDomain_domainGame
 Game domain, pointer into the config file. More...
 

Static Private Attributes

static const char * kDomainApp = "xoreos"
 The name of the application domain. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Common::Singleton< ConfigManager >
static ConfigManagerinstance ()
 
static void destroy ()
 
- Protected Types inherited from Common::Singleton< ConfigManager >
typedef ConfigManager SingletonBaseType
 
- Protected Member Functions inherited from Common::Singleton< ConfigManager >
 Singleton ()
 
virtual ~Singleton ()
 

Detailed Description

The global config manager, storing all config keys.

Definition at line 51 of file configman.h.

Constructor & Destructor Documentation

◆ ConfigManager()

Common::ConfigManager::ConfigManager ( )

Definition at line 42 of file configman.cpp.

References _domainCommandline, and _domainDefaultApp.

◆ ~ConfigManager()

Common::ConfigManager::~ConfigManager ( )

Definition at line 47 of file configman.cpp.

Member Function Documentation

◆ changed()

bool Common::ConfigManager::changed ( ) const

Was at least on setting changed?

Definition at line 75 of file configman.cpp.

References _changed.

◆ clear()

void Common::ConfigManager::clear ( )

Clear everything except the command line options.

Definition at line 54 of file configman.cpp.

References _changed, _config, _domainApp, _domainDefaultApp, _domainDefaultGame, _domainGame, and _domainGameTemp.

Referenced by create(), and load().

Here is the caller graph for this function:

◆ clearCommandline()

void Common::ConfigManager::clearCommandline ( )

Clear the command line options.

Definition at line 67 of file configman.cpp.

References _domainCommandline.

◆ create()

void Common::ConfigManager::create ( )

Create a new, empty config.

Definition at line 153 of file configman.cpp.

References _config, _domainApp, clear(), and kDomainApp.

Here is the call graph for this function:

◆ createGame()

UString Common::ConfigManager::createGame ( const UString path,
UString  target = "" 
)

Create the game domain with this path and target.

Definition at line 217 of file configman.cpp.

References _changed, _config, Common::FilePath::canonicalize(), createGameID(), Common::UString::empty(), and Common::ConfigDomain::setString().

Here is the call graph for this function:

◆ createGameID()

UString Common::ConfigManager::createGameID ( const UString path)
private

Definition at line 187 of file configman.cpp.

References _config, Common::UString::begin(), Common::UString::c_str(), Common::FilePath::canonicalize(), Common::UString::empty(), Common::UString::end(), Common::UString::format(), Common::FilePath::getStem(), and Common::UString::isAlNum().

Referenced by createGame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileExists()

bool Common::ConfigManager::fileExists ( ) const

Does the config file exist?

Definition at line 71 of file configman.cpp.

References getConfigFile(), and Common::FilePath::isRegularFile().

Here is the call graph for this function:

◆ findGame()

UString Common::ConfigManager::findGame ( const UString path)

Find the game domain using this path.

Definition at line 161 of file configman.cpp.

References _config, Common::FilePath::canonicalize(), Common::UString::empty(), and kDomainApp.

Here is the call graph for this function:

◆ getBool() [1/2]

bool Common::ConfigManager::getBool ( const UString key) const

Definition at line 298 of file configman.cpp.

References getDefaultKey(), getKey(), and Common::parseString().

Referenced by save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBool() [2/2]

bool Common::ConfigManager::getBool ( const UString key,
bool  def 
) const

Definition at line 339 of file configman.cpp.

References Common::exceptionDispatcherWarning(), getKey(), and Common::parseString().

Here is the call graph for this function:

◆ getConfigFile()

UString Common::ConfigManager::getConfigFile ( ) const

Return the config file that's currently in use.

Definition at line 513 of file configman.cpp.

References _configFile, Common::UString::empty(), and getDefaultConfigFile().

Referenced by fileExists(), load(), and save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDefaultBool()

bool Common::ConfigManager::getDefaultBool ( const UString key) const

Definition at line 488 of file configman.cpp.

References getDefaultKey(), and Common::parseString().

Here is the call graph for this function:

◆ getDefaultConfigFile()

UString Common::ConfigManager::getDefaultConfigFile ( )
staticprivate

Definition at line 520 of file configman.cpp.

References Common::FilePath::getConfigDirectory().

Referenced by getConfigFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDefaultDouble()

double Common::ConfigManager::getDefaultDouble ( const UString key) const

Definition at line 502 of file configman.cpp.

References getDefaultKey(), and Common::parseString().

Here is the call graph for this function:

◆ getDefaultInt()

int Common::ConfigManager::getDefaultInt ( const UString key) const

Definition at line 495 of file configman.cpp.

References getDefaultKey(), and Common::parseString().

Here is the call graph for this function:

◆ getDefaultKey()

UString Common::ConfigManager::getDefaultKey ( const UString key) const

Definition at line 473 of file configman.cpp.

References _domainDefaultApp, _domainDefaultGame, Common::UString::c_str(), and getKey().

Referenced by getBool(), getDefaultBool(), getDefaultDouble(), getDefaultInt(), getDefaultString(), getDouble(), getInt(), and getString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDefaultString()

UString Common::ConfigManager::getDefaultString ( const UString key) const

Definition at line 484 of file configman.cpp.

References getDefaultKey().

Here is the call graph for this function:

◆ getDouble() [1/2]

double Common::ConfigManager::getDouble ( const UString key) const

Definition at line 320 of file configman.cpp.

References getDefaultKey(), getKey(), and Common::parseString().

Here is the call graph for this function:

◆ getDouble() [2/2]

double Common::ConfigManager::getDouble ( const UString key,
double  def 
) const

Definition at line 369 of file configman.cpp.

References Common::exceptionDispatcherWarning(), getKey(), and Common::parseString().

Here is the call graph for this function:

◆ getInt() [1/2]

int Common::ConfigManager::getInt ( const UString key) const

Definition at line 309 of file configman.cpp.

References getDefaultKey(), getKey(), and Common::parseString().

Here is the call graph for this function:

◆ getInt() [2/2]

int Common::ConfigManager::getInt ( const UString key,
int  def 
) const

Definition at line 354 of file configman.cpp.

References Common::exceptionDispatcherWarning(), getKey(), and Common::parseString().

Here is the call graph for this function:

◆ getKey() [1/2]

bool Common::ConfigManager::getKey ( const UString key,
UString value 
) const

Definition at line 280 of file configman.cpp.

References _domainApp, _domainCommandline, _domainDefaultApp, _domainDefaultGame, _domainGame, and _domainGameTemp.

Referenced by getBool(), getDefaultKey(), getDouble(), getInt(), getString(), and setKey().

Here is the caller graph for this function:

◆ getKey() [2/2]

bool Common::ConfigManager::getKey ( const ConfigDomain domain,
const UString key,
UString value 
) const
private

Definition at line 529 of file configman.cpp.

References Common::ConfigDomain::getKey().

Here is the call graph for this function:

◆ getString() [1/2]

UString Common::ConfigManager::getString ( const UString key) const

Definition at line 290 of file configman.cpp.

References getDefaultKey(), and getKey().

Here is the call graph for this function:

◆ getString() [2/2]

UString Common::ConfigManager::getString ( const UString key,
const UString def 
) const

Definition at line 331 of file configman.cpp.

References getKey().

Here is the call graph for this function:

◆ hasDefaultKey()

bool Common::ConfigManager::hasDefaultKey ( const UString key) const

Definition at line 468 of file configman.cpp.

References _domainDefaultApp, _domainDefaultGame, and hasKey().

Here is the call graph for this function:

◆ hasGame()

bool Common::ConfigManager::hasGame ( const UString gameID)

Does the specified game domain exist?

Definition at line 234 of file configman.cpp.

References _config.

◆ hasKey() [1/2]

bool Common::ConfigManager::hasKey ( const UString key) const

Definition at line 273 of file configman.cpp.

References _domainApp, _domainCommandline, and _domainGame.

Referenced by hasDefaultKey().

Here is the caller graph for this function:

◆ hasKey() [2/2]

bool Common::ConfigManager::hasKey ( const ConfigDomain domain,
const UString key 
) const
private

Definition at line 525 of file configman.cpp.

References Common::ConfigDomain::hasKey().

Here is the call graph for this function:

◆ isInGame()

bool Common::ConfigManager::isInGame ( ) const

Are we currently in a game?

Definition at line 269 of file configman.cpp.

References _domainDefaultGame, _domainGame, and _domainGameTemp.

◆ load() [1/2]

bool Common::ConfigManager::load ( )

Load from the default config file.

Definition at line 79 of file configman.cpp.

References Common::UString::c_str(), clear(), Common::exceptionDispatcherWarning(), getConfigFile(), Common::FilePath::isRegularFile(), Common::kOpenError, and Common::ReadFile::open().

Here is the call graph for this function:

◆ load() [2/2]

void Common::ConfigManager::load ( SeekableReadStream stream)

Load from a generic read stream.

Definition at line 104 of file configman.cpp.

References _config, _domainApp, clear(), and kDomainApp.

Here is the call graph for this function:

◆ save() [1/2]

bool Common::ConfigManager::save ( )

◆ save() [2/2]

void Common::ConfigManager::save ( WriteStream stream,
bool  clearChanged = false 
)

Save to a generic write stream.

Definition at line 142 of file configman.cpp.

References _changed, and _config.

◆ setBool() [1/2]

void Common::ConfigManager::setBool ( const UString key,
bool  value,
bool  update = false 
)

Definition at line 410 of file configman.cpp.

References Common::composeString(), and setKey().

Here is the call graph for this function:

◆ setBool() [2/2]

void Common::ConfigManager::setBool ( ConfigRealm  realm,
const UString key,
bool  value 
)

Definition at line 444 of file configman.cpp.

References Common::composeString(), and setKey().

Here is the call graph for this function:

◆ setCommandlineKey()

void Common::ConfigManager::setCommandlineKey ( const UString key,
const UString value 
)

Set a config value that came from the command line.

Definition at line 509 of file configman.cpp.

References _domainCommandline, and setKey().

Here is the call graph for this function:

◆ setConfigFile()

void Common::ConfigManager::setConfigFile ( const UString file = "")

Set the config file to use.

Definition at line 50 of file configman.cpp.

References _configFile.

◆ setDefaults()

void Common::ConfigManager::setDefaults ( )

Overwrite the current config with the defaults.

Definition at line 456 of file configman.cpp.

References _changed, _domainApp, _domainDefaultApp, _domainDefaultGame, _domainGame, and Common::ConfigDomain::set().

Here is the call graph for this function:

◆ setDouble() [1/2]

void Common::ConfigManager::setDouble ( const UString key,
double  value,
bool  update = false 
)

Definition at line 418 of file configman.cpp.

References Common::composeString(), and setKey().

Here is the call graph for this function:

◆ setDouble() [2/2]

void Common::ConfigManager::setDouble ( ConfigRealm  realm,
const UString key,
double  value 
)

Definition at line 452 of file configman.cpp.

References Common::composeString(), and setKey().

Here is the call graph for this function:

◆ setGame()

bool Common::ConfigManager::setGame ( const UString gameID = "")

Set the game domain to gameID.

Definition at line 241 of file configman.cpp.

References _config, _domainDefaultGame, _domainGame, _domainGameTemp, and Common::UString::empty().

Here is the call graph for this function:

◆ setInt() [1/2]

void Common::ConfigManager::setInt ( const UString key,
int  value,
bool  update = false 
)

Definition at line 414 of file configman.cpp.

References Common::composeString(), and setKey().

Here is the call graph for this function:

◆ setInt() [2/2]

void Common::ConfigManager::setInt ( ConfigRealm  realm,
const UString key,
int  value 
)

Definition at line 448 of file configman.cpp.

References Common::composeString(), and setKey().

Here is the call graph for this function:

◆ setKey() [1/3]

void Common::ConfigManager::setKey ( const UString key,
const UString value,
bool  update = false 
)

Definition at line 384 of file configman.cpp.

References _changed, _domainApp, _domainCommandline, _domainGame, and getKey().

Referenced by setBool(), setCommandlineKey(), setDouble(), setInt(), setKey(), and setString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setKey() [2/3]

void Common::ConfigManager::setKey ( ConfigRealm  realm,
const UString key,
const UString value 
)

Set a config value in a specific realm.

Definition at line 422 of file configman.cpp.

References _domainDefaultApp, _domainDefaultGame, _domainGameTemp, Common::kConfigRealmDefault, Common::kConfigRealmGameTemp, and setKey().

Here is the call graph for this function:

◆ setKey() [3/3]

bool Common::ConfigManager::setKey ( ConfigDomain domain,
const UString key,
const UString value 
)
private

Definition at line 533 of file configman.cpp.

References Common::ConfigDomain::setKey().

Here is the call graph for this function:

◆ setString() [1/2]

void Common::ConfigManager::setString ( const UString key,
const UString value,
bool  update = false 
)

Definition at line 406 of file configman.cpp.

References setKey().

Here is the call graph for this function:

◆ setString() [2/2]

void Common::ConfigManager::setString ( ConfigRealm  realm,
const UString key,
const UString value 
)

Definition at line 440 of file configman.cpp.

References setKey().

Here is the call graph for this function:

Member Data Documentation

◆ _changed

bool Common::ConfigManager::_changed
private

Definition at line 151 of file configman.h.

Referenced by changed(), clear(), createGame(), save(), setDefaults(), and setKey().

◆ _config

ScopedPtr<ConfigFile> Common::ConfigManager::_config
private

The actual config.

Definition at line 153 of file configman.h.

Referenced by clear(), create(), createGame(), createGameID(), findGame(), hasGame(), load(), save(), and setGame().

◆ _configFile

UString Common::ConfigManager::_configFile
private

The config file to use.

Definition at line 149 of file configman.h.

Referenced by getConfigFile(), and setConfigFile().

◆ _domainApp

ConfigDomain* Common::ConfigManager::_domainApp
private

Application domain, pointer into the config file.

Definition at line 160 of file configman.h.

Referenced by clear(), create(), getKey(), hasKey(), load(), setDefaults(), and setKey().

◆ _domainCommandline

ScopedPtr<ConfigDomain> Common::ConfigManager::_domainCommandline
private

Command line domain.

Definition at line 157 of file configman.h.

Referenced by clearCommandline(), ConfigManager(), getKey(), hasKey(), setCommandlineKey(), and setKey().

◆ _domainDefaultApp

ScopedPtr<ConfigDomain> Common::ConfigManager::_domainDefaultApp
private

Application defaults domain.

Definition at line 155 of file configman.h.

Referenced by clear(), ConfigManager(), getDefaultKey(), getKey(), hasDefaultKey(), setDefaults(), and setKey().

◆ _domainDefaultGame

ScopedPtr<ConfigDomain> Common::ConfigManager::_domainDefaultGame
private

Game defaults domain.

Definition at line 156 of file configman.h.

Referenced by clear(), getDefaultKey(), getKey(), hasDefaultKey(), isInGame(), setDefaults(), setGame(), and setKey().

◆ _domainGame

ConfigDomain* Common::ConfigManager::_domainGame
private

Game domain, pointer into the config file.

Definition at line 161 of file configman.h.

Referenced by clear(), getKey(), hasKey(), isInGame(), setDefaults(), setGame(), and setKey().

◆ _domainGameTemp

ScopedPtr<ConfigDomain> Common::ConfigManager::_domainGameTemp
private

Temporary game settings domain.

Definition at line 158 of file configman.h.

Referenced by clear(), getKey(), isInGame(), setGame(), and setKey().

◆ kDomainApp

const char * Common::ConfigManager::kDomainApp = "xoreos"
staticprivate

The name of the application domain.

Definition at line 147 of file configman.h.

Referenced by create(), findGame(), and load().


The documentation for this class was generated from the following files: