Orxonox
0.0.5 Codename: Arcturus
|
Child class of ConfigFile, used to store the settings of the game. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/config/SettingsConfigFile.h>
Public Types | |
typedef std::multimap< std::string, std::pair< std::string, ConfigValueContainer * > > | ContainerMap |
Public Member Functions | |
SettingsConfigFile (const std::string &filename) | |
Constructor: Activates the console commands. More... | |
~SettingsConfigFile () | |
Destructor: Deactivates the console commands. More... | |
void | addConfigValueContainer (ConfigValueContainer *container) |
Registers a new config value container. More... | |
void | clean (bool bCleanComments=false) |
Removes entries and sections from the file that don't exist anymore (i.e. More... | |
void | config (const std::string §ion, const std::string &entry, const std::string &value) |
Console-command: Changes the value of an entry and stores it the file. More... | |
std::string | getConfig (const std::string §ion, const std::string &entry) |
Console-command: Returns the value of a given entry. More... | |
ContainerMap::const_iterator | getContainerLowerBound (const std::string section) |
Returns the lower-bound-iterator of the config value containers for the given section. More... | |
ContainerMap::const_iterator | getContainerUpperBound (const std::string section) |
Returns the upper-bound-iterator of the config value containers for the given section. More... | |
const std::set< std::string > & | getSectionNames () |
Returns a set containing the names of all sections in this config file. More... | |
virtual void | load () override |
Loads the config file and updates the config value containers. More... | |
void | removeConfigValueContainer (ConfigValueContainer *container) |
Unregisters a config value container. More... | |
void | setFilename (const std::string &filename) |
Changes the file-name. More... | |
void | tconfig (const std::string §ion, const std::string &entry, const std::string &value) |
Console-command: Changes the value of an entry, but doesn't store it in the file (it's only a temporary change). More... | |
Public Member Functions inherited from orxonox::ConfigFile | |
ConfigFile (const std::string &filename, bool bCopyFallbackFile=true) | |
Constructor: Initializes the config file. More... | |
virtual | ~ConfigFile () |
Destructor: Deletes all sections and entries. More... | |
virtual void | clear () |
Deletes all sections (which again delete all their values) and clears the list of sections. More... | |
void | deleteVectorEntries (const std::string §ion, const std::string &name, unsigned int startindex=0) |
Deletes all elements of a config vector if their index is greater or equal to startindex. More... | |
const std::string & | getFilename () |
Returns the file-name of this config file. More... | |
const std::string & | getOrCreateValue (const std::string §ion, const std::string &name, const std::string &fallback, bool bString) |
Returns the value of a given entry in the config file. More... | |
const std::string & | getOrCreateValue (const std::string §ion, const std::string &name, unsigned int index, const std::string &fallback, bool bString) |
Returns the value of a given element of a vector in the config file. More... | |
const std::string & | getValue (const std::string §ion, const std::string &name, bool bString) |
Returns the value of a given entry in the config file. More... | |
const std::string & | getValue (const std::string §ion, const std::string &name, unsigned int index, bool bString) |
Returns the value of a given element of a vector in the config file. More... | |
unsigned int | getVectorSize (const std::string §ion, const std::string &name) const |
Returns the size of a config vector. More... | |
virtual void | save () const |
Writes the sections and values to the hard-disk. More... | |
virtual void | saveAs (const std::string &filename) const |
Writes the sections and values to a given file on the hard-disk. More... | |
void | setValue (const std::string §ion, const std::string &name, const std::string &value, bool bString) |
Stores a value in the config file. More... | |
void | setValue (const std::string §ion, const std::string &name, unsigned int index, const std::string &value, bool bString) |
Stores the value of an element of a vector in the config file. More... | |
Static Public Member Functions | |
static SettingsConfigFile & | getInstance () |
Static Public Member Functions inherited from orxonox::Singleton< SettingsConfigFile > | |
static bool | exists () |
Tells whether the singleton has been created. More... | |
static SettingsConfigFile & | getInstance () |
Returns a reference to the singleton instance. More... | |
Private Member Functions | |
bool | configImpl (const std::string §ion, const std::string &entry, const std::string &value, bool(ConfigValueContainer::*function)(const MultiType &)) |
Changes the value of an entry, depending on function, either by using "set" or "tset". More... | |
void | updateConfigValues () |
Updates all config value containers. More... | |
Private Attributes | |
ContainerMap | containers_ |
Stores all config value containers. More... | |
std::set< std::string > | sectionNames_ |
Stores all section names. More... | |
Static Private Attributes | |
static SettingsConfigFile * | singletonPtr_s = nullptr |
The singleton pointer. More... | |
Friends | |
class | Singleton< SettingsConfigFile > |
Additional Inherited Members | |
Static Public Attributes inherited from orxonox::ConfigFile | |
static const char * | DEFAULT_CONFIG_FOLDER = "defaultConfig" |
The folder where the default config files will be stored. More... | |
Protected Member Functions inherited from orxonox::ConfigFile | |
ConfigFileSection * | getOrCreateSection (const std::string §ion) |
Returns a pointer to the section with given name. More... | |
ConfigFileSection * | getSection (const std::string §ion) const |
Returns a pointer to the section with given name (or nullptr if the section doesn't exist). More... | |
Protected Member Functions inherited from orxonox::Singleton< SettingsConfigFile > | |
Singleton () | |
Constructor sets the singleton instance pointer. More... | |
virtual | ~Singleton () |
Destructor resets the singleton instance pointer. More... | |
Protected Attributes inherited from orxonox::ConfigFile | |
std::list< ConfigFileSection * > | sections_ |
A list of sections in this config file. More... | |
Child class of ConfigFile, used to store the settings of the game.
In addition to ConfigFile, this class provides an interface to manipulate the settings with console commands and to cache entries in instances of ConfigValueContainer.
SettingsConfigFile is a Singleton, meaning there's only one instance of this class (and thus only one config file that stores settings).
typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*> > orxonox::SettingsConfigFile::ContainerMap |
orxonox::SettingsConfigFile::SettingsConfigFile | ( | const std::string & | filename | ) |
Constructor: Activates the console commands.
orxonox::SettingsConfigFile::~SettingsConfigFile | ( | ) |
Destructor: Deactivates the console commands.
void orxonox::SettingsConfigFile::addConfigValueContainer | ( | ConfigValueContainer * | container | ) |
Registers a new config value container.
void orxonox::SettingsConfigFile::clean | ( | bool | bCleanComments = false | ) |
Removes entries and sections from the file that don't exist anymore (i.e.
if there's no corresponding config value container).
bCleanComments | If true, comments are also removed from the file |
void orxonox::SettingsConfigFile::config | ( | const std::string & | section, |
const std::string & | entry, | ||
const std::string & | value | ||
) |
Console-command: Changes the value of an entry and stores it the file.
section | The section of the config value |
entry | The name of the config value |
value | The new value |
|
private |
Changes the value of an entry, depending on function, either by using "set" or "tset".
section | The section of the config value |
entry | The name of the config value |
value | The new value |
function | The function ("set" or "tset") that will be used to change the value. |
std::string orxonox::SettingsConfigFile::getConfig | ( | const std::string & | section, |
const std::string & | entry | ||
) |
Console-command: Returns the value of a given entry.
section | The section of the config value |
entry | The name of the config value |
|
inline |
Returns the lower-bound-iterator of the config value containers for the given section.
|
inline |
Returns the upper-bound-iterator of the config value containers for the given section.
|
inlinestatic |
|
inline |
Returns a set containing the names of all sections in this config file.
|
overridevirtual |
Loads the config file and updates the config value containers.
Reimplemented from orxonox::ConfigFile.
void orxonox::SettingsConfigFile::removeConfigValueContainer | ( | ConfigValueContainer * | container | ) |
Unregisters a config value container.
void orxonox::SettingsConfigFile::setFilename | ( | const std::string & | filename | ) |
Changes the file-name.
void orxonox::SettingsConfigFile::tconfig | ( | const std::string & | section, |
const std::string & | entry, | ||
const std::string & | value | ||
) |
Console-command: Changes the value of an entry, but doesn't store it in the file (it's only a temporary change).
section | The section of the config value |
entry | The name of the config value |
value | The new value |
|
private |
Updates all config value containers.
|
friend |
|
private |
Stores all config value containers.
|
private |
Stores all section names.
|
staticprivate |
The singleton pointer.