Orxonox  0.0.5 Codename: Arcturus
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
orxonox::SettingsConfigFile Class Reference

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>

Inheritance diagram for orxonox::SettingsConfigFile:
orxonox::ConfigFile orxonox::Singleton< SettingsConfigFile >

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 &section, 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 &section, 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 &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). 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 &section, 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 &section, 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 &section, 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 &section, 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 &section, 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 &section, 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 &section, const std::string &name, const std::string &value, bool bString)
 Stores a value in the config file. More...
 
void setValue (const std::string &section, 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 SettingsConfigFilegetInstance ()
 
- Static Public Member Functions inherited from orxonox::Singleton< SettingsConfigFile >
static bool exists ()
 Tells whether the singleton has been created. More...
 
static SettingsConfigFilegetInstance ()
 Returns a reference to the singleton instance. More...
 

Private Member Functions

bool configImpl (const std::string &section, 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 SettingsConfigFilesingletonPtr_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
ConfigFileSectiongetOrCreateSection (const std::string &section)
 Returns a pointer to the section with given name. More...
 
ConfigFileSectiongetSection (const std::string &section) 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...
 

Detailed Description

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).

Member Typedef Documentation

typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*> > orxonox::SettingsConfigFile::ContainerMap

Constructor & Destructor Documentation

orxonox::SettingsConfigFile::SettingsConfigFile ( const std::string &  filename)

Constructor: Activates the console commands.

orxonox::SettingsConfigFile::~SettingsConfigFile ( )

Destructor: Deactivates the console commands.

Member Function Documentation

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).

Parameters
bCleanCommentsIf 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.

Parameters
sectionThe section of the config value
entryThe name of the config value
valueThe new value
bool orxonox::SettingsConfigFile::configImpl ( const std::string &  section,
const std::string &  entry,
const std::string &  value,
bool(ConfigValueContainer::*)(const MultiType &)  function 
)
private

Changes the value of an entry, depending on function, either by using "set" or "tset".

Parameters
sectionThe section of the config value
entryThe name of the config value
valueThe new value
functionThe 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.

Parameters
sectionThe section of the config value
entryThe name of the config value
ContainerMap::const_iterator orxonox::SettingsConfigFile::getContainerLowerBound ( const std::string  section)
inline

Returns the lower-bound-iterator of the config value containers for the given section.

ContainerMap::const_iterator orxonox::SettingsConfigFile::getContainerUpperBound ( const std::string  section)
inline

Returns the upper-bound-iterator of the config value containers for the given section.

static SettingsConfigFile& orxonox::SettingsConfigFile::getInstance ( )
inlinestatic
const std::set<std::string>& orxonox::SettingsConfigFile::getSectionNames ( )
inline

Returns a set containing the names of all sections in this config file.

void orxonox::SettingsConfigFile::load ( )
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).

Parameters
sectionThe section of the config value
entryThe name of the config value
valueThe new value
void orxonox::SettingsConfigFile::updateConfigValues ( )
private

Friends And Related Function Documentation

friend class Singleton< SettingsConfigFile >
friend

Member Data Documentation

ContainerMap orxonox::SettingsConfigFile::containers_
private
std::set<std::string> orxonox::SettingsConfigFile::sectionNames_
private

Stores all section names.

SettingsConfigFile * orxonox::SettingsConfigFile::singletonPtr_s = nullptr
staticprivate

The singleton pointer.


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