ScummVM API documentation
Common::ConfigManager Class Reference

#include <config-manager.h>

Inheritance diagram for Common::ConfigManager:
Common::Singleton< ConfigManager > Common::NonCopyable

Classes

class  Domain
 

Public Types

typedef HashMap< String, Domain, IgnoreCase_Hash, IgnoreCase_EqualToDomainMap
 

Public Member Functions

bool loadDefaultConfigFile (const Path &fallbackFilename)
 
bool loadConfigFile (const Path &filename, const Path &fallbackFilename)
 
DomaingetDomain (const String &domName)
 
const DomaingetDomain (const String &domName) const
 
bool hasDefault (const String &key) const
 
void setAndFlush (const String &key, const Common::String &value)
 
Generic access methods

No domain specified, use the values from the various domains in the order of their priority.

bool hasKey (const String &key) const
 
const Stringget (const String &key) const
 
void set (const String &key, const String &value)
 
Domain-specific access methods

Access one specific domain and modify it.

TBD: Get rid of most of those if possible, or at least reduce their usage, by using getDomain as often as possible. For example in the options dialog code.

bool hasKey (const String &key, const String &domName) const
 
const Stringget (const String &key, const String &domName) const
 
void set (const String &key, const String &value, const String &domName)
 
void removeKey (const String &key, const String &domName)
 

Static Public Attributes

static char const *const kApplicationDomain
 
static char const *const kTransientDomain
 
static char const *const kKeymapperDomain
 
static char const *const kSessionDomain
 

Additional convenience accessors

int getInt (const String &key, const String &domName=String()) const
 
bool getBool (const String &key, const String &domName=String()) const
 
Path getPath (const String &key, const String &domName=String()) const
 
float getFloat (const String &key, const String &domName=String()) const
 
void setInt (const String &key, int value, const String &domName=String())
 
void setBool (const String &key, bool value, const String &domName=String())
 
void setPath (const String &key, const Path &value, const String &domName=String())
 
void setFloat (const String &key, float value, const String &domName=String())
 
void registerDefault (const String &key, const String &value)
 
void registerDefault (const String &key, const char *value)
 
void registerDefault (const String &key, int value)
 
void registerDefault (const String &key, bool value)
 
void registerDefault (const String &key, const Path &value)
 
void flushToDisk ()
 
void setActiveDomain (const String &domName)
 
DomaingetActiveDomain ()
 
const DomaingetActiveDomain () const
 
const StringgetActiveDomainName () const
 
void addGameDomain (const String &domName)
 
void removeGameDomain (const String &domName)
 
void renameGameDomain (const String &oldName, const String &newName)
 
void addMiscDomain (const String &domName)
 
void removeMiscDomain (const String &domName)
 
void renameMiscDomain (const String &oldName, const String &newName)
 
bool hasGameDomain (const String &domName) const
 
bool hasMiscDomain (const String &domName) const
 
bool isKeyTemporary (const String &key) const
 
const DomainMapgetGameDomains () const
 
DomainMap::iterator beginGameDomains ()
 
DomainMap::iterator endGameDomains ()
 
const PathgetCustomConfigFileName ()
 
void copyFrom (ConfigManager &source)
 
static void defragment ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Common::Singleton< ConfigManager >
static bool hasInstance ()
 
static ConfigManagerinstance ()
 
static void destroy ()
 
- Protected Types inherited from Common::Singleton< ConfigManager >
typedef ConfigManager SingletonBaseType
 
- Static Protected Attributes inherited from Common::Singleton< ConfigManager >
static ConfigManager_singleton
 

Detailed Description

The (singleton) configuration manager, used to query & set configuration values using string keys.

TBD: Implement the callback based notification system (outlined below) which sends out notifications to interested parties whenever the value of some specific (or any) configuration key changes.

Member Typedef Documentation

◆ DomainMap

A hash map of existing configuration domains.

Member Function Documentation

◆ loadDefaultConfigFile()

bool Common::ConfigManager::loadDefaultConfigFile ( const Path fallbackFilename)

Load the default configuration file.

◆ loadConfigFile()

bool Common::ConfigManager::loadConfigFile ( const Path filename,
const Path fallbackFilename 
)

Load a specific configuration file.

◆ getDomain() [1/2]

Domain* Common::ConfigManager::getDomain ( const String domName)

Retrieve the config domain with the given name.

Parameters
domNameName of the domain to retrieve.
Returns
Pointer to the domain, or 0 if the domain does not exist.

◆ getDomain() [2/2]

const Domain* Common::ConfigManager::getDomain ( const String domName) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ hasKey() [1/2]

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

Check if a given key exists.

◆ get() [1/2]

const String& Common::ConfigManager::get ( const String key) const

Get the value of a key.

◆ set() [1/2]

void Common::ConfigManager::set ( const String key,
const String value 
)

Assign a value to a key.

◆ hasDefault()

bool Common::ConfigManager::hasDefault ( const String key) const

Indicate if a default value has been set for the given key.

◆ setAndFlush()

void Common::ConfigManager::setAndFlush ( const String key,
const Common::String value 
)

Update a configuration entry for the active domain and flush the configuration file to disk if the value changed.

◆ hasKey() [2/2]

bool Common::ConfigManager::hasKey ( const String key,
const String domName 
) const

Check if a given key exists in the domName domain.

◆ get() [2/2]

const String& Common::ConfigManager::get ( const String key,
const String domName 
) const

Get the value of a key from the domName domain.

◆ set() [2/2]

void Common::ConfigManager::set ( const String key,
const String value,
const String domName 
)

Assign a value to a key in the domName domain.

◆ removeKey()

void Common::ConfigManager::removeKey ( const String key,
const String domName 
)

Remove a key to a key from the domName domain.

◆ getInt()

int Common::ConfigManager::getInt ( const String key,
const String domName = String() 
) const

Get integer value.

◆ getBool()

bool Common::ConfigManager::getBool ( const String key,
const String domName = String() 
) const

Get Boolean value.

◆ getPath()

Path Common::ConfigManager::getPath ( const String key,
const String domName = String() 
) const

Get path value.

◆ getFloat()

float Common::ConfigManager::getFloat ( const String key,
const String domName = String() 
) const

Get float value.

◆ setInt()

void Common::ConfigManager::setInt ( const String key,
int  value,
const String domName = String() 
)

Set integer value.

◆ setBool()

void Common::ConfigManager::setBool ( const String key,
bool  value,
const String domName = String() 
)

Set Boolean value.

◆ setPath()

void Common::ConfigManager::setPath ( const String key,
const Path value,
const String domName = String() 
)

Set path value.

◆ setFloat()

void Common::ConfigManager::setFloat ( const String key,
float  value,
const String domName = String() 
)

Set float value.

◆ registerDefault() [1/5]

void Common::ConfigManager::registerDefault ( const String key,
const String value 
)

Register a value as the default.

◆ registerDefault() [2/5]

void Common::ConfigManager::registerDefault ( const String key,
const char *  value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ registerDefault() [3/5]

void Common::ConfigManager::registerDefault ( const String key,
int  value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ registerDefault() [4/5]

void Common::ConfigManager::registerDefault ( const String key,
bool  value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ registerDefault() [5/5]

void Common::ConfigManager::registerDefault ( const String key,
const Path value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ flushToDisk()

void Common::ConfigManager::flushToDisk ( )

Flush configuration to disk.

◆ setActiveDomain()

void Common::ConfigManager::setActiveDomain ( const String domName)

Set the given domain as active.

◆ getActiveDomain() [1/2]

Domain* Common::ConfigManager::getActiveDomain ( )
inline

Get the active domain.

◆ getActiveDomain() [2/2]

const Domain* Common::ConfigManager::getActiveDomain ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getActiveDomainName()

const String& Common::ConfigManager::getActiveDomainName ( ) const
inline

Get the name of the active domain.

◆ addGameDomain()

void Common::ConfigManager::addGameDomain ( const String domName)

Add a new game domain.

◆ removeGameDomain()

void Common::ConfigManager::removeGameDomain ( const String domName)

Remove a game domain.

◆ renameGameDomain()

void Common::ConfigManager::renameGameDomain ( const String oldName,
const String newName 
)

Rename a game domain.

◆ addMiscDomain()

void Common::ConfigManager::addMiscDomain ( const String domName)

Add a miscellaneous domain.

◆ removeMiscDomain()

void Common::ConfigManager::removeMiscDomain ( const String domName)

Remove a miscellaneous domain.

◆ renameMiscDomain()

void Common::ConfigManager::renameMiscDomain ( const String oldName,
const String newName 
)

Rename a miscellaneous domain.

◆ hasGameDomain()

bool Common::ConfigManager::hasGameDomain ( const String domName) const

Check if a specific game domain exists in the DomainMap.

◆ hasMiscDomain()

bool Common::ConfigManager::hasMiscDomain ( const String domName) const

Check if a specific miscellaneous domain exists in the DomainMap.

◆ isKeyTemporary()

bool Common::ConfigManager::isKeyTemporary ( const String key) const

Check if a specific key exists in either transient or session domain.

◆ getGameDomains()

const DomainMap& Common::ConfigManager::getGameDomains ( ) const
inline

Return all game domains in the DomainMap.

◆ beginGameDomains()

DomainMap::iterator Common::ConfigManager::beginGameDomains ( )
inline

Return the beginning position of game domains.

◆ endGameDomains()

DomainMap::iterator Common::ConfigManager::endGameDomains ( )
inline

Return the ending position of game domains.

◆ getCustomConfigFileName()

const Path& Common::ConfigManager::getCustomConfigFileName ( )
inline

Return the custom config file being used, or an empty string when using the default config file

◆ defragment()

static void Common::ConfigManager::defragment ( )
static

Move the configuration in memory to reduce fragmentation.

◆ copyFrom()

void Common::ConfigManager::copyFrom ( ConfigManager source)

Copy from a ConfigManager instance.

Member Data Documentation

◆ kApplicationDomain

char const* const Common::ConfigManager::kApplicationDomain
static

The name of the application domain (normally 'scummvm').

◆ kTransientDomain

char const* const Common::ConfigManager::kTransientDomain
static

The transient (pseudo) domain.

◆ kKeymapperDomain

char const* const Common::ConfigManager::kKeymapperDomain
static

The name of keymapper domain used to store the key maps.

◆ kSessionDomain

char const* const Common::ConfigManager::kSessionDomain
static

The name of the session domain where configs are put for the entire session or until they are overwritten or removed. These settings don't get saved to disk.


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