Orxonox
0.0.5 Codename: Arcturus
|
The ConfigValuecontainer contains all needed information about a configurable variable. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/config/ConfigValueContainer.h>
Public Member Functions | |
template<class D , class V > | |
ConfigValueContainer (ConfigFileType::Value type, Identifier *identifier, const std::string §ionname, const std::string &varname, const D &defvalue, const V &value) | |
Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. More... | |
template<class D , class V > | |
ConfigValueContainer (ConfigFileType::Value type, Identifier *identifier, const std::string §ionname, const std::string &varname, const std::vector< D > &defvalue, const std::vector< V > &value) | |
Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. More... | |
~ConfigValueContainer () | |
Destructor: Deletes the callback object if necessary. More... | |
bool | add (const MultiType &input) |
Adds a new entry to the end of the vector. More... | |
template<class T > | |
ConfigValueContainer & | callback (T *object, void(T::*function)(void)) |
Adds a callback function, that gets called after getValue() if the newly assigned value differs from the old value of the variable. More... | |
ConfigValueContainer & | description (const std::string &description) |
Adds a description to the config-value. More... | |
const std::string & | getDescription () const |
Returns the description of the config-value. More... | |
Identifier * | getIdentifier () const |
Returns the associated identifier (can be nullptr). More... | |
const std::string & | getName () const |
Returns the name of this container. More... | |
const std::string & | getSectionName () const |
Returns the name of the section this config value is in. More... | |
std::string | getTypename () const |
Returns the typename of the assigned config-value. More... | |
template<typename T , class C > | |
ConfigValueContainer & | getValue (T *value, C *object) |
Returns the configured value. More... | |
template<typename T , class C > | |
ConfigValueContainer & | getValue (std::vector< T > *value, C *object) |
Returns the configured vector. More... | |
unsigned int | getVectorSize () const |
Returns the vectors size (or zero if it's not a vector). More... | |
bool | isVector () const |
Returns true if this config-value is a vector. More... | |
bool | remove (unsigned int index) |
Removes an existing entry from the vector. More... | |
bool | reset () |
Sets the value of the variable back to the default value and resets the config-file entry. More... | |
bool | set (const MultiType &input) |
Assigns a new value to the config-value of all objects and writes the change into the config-file. More... | |
bool | set (unsigned int index, const MultiType &input) |
Assigns a new value to the config-value of all objects and writes the change into the config-file. More... | |
std::string | toString () const |
Converts the config-value to a string. More... | |
bool | tset (const MultiType &input) |
Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary). More... | |
bool | tset (unsigned int index, const MultiType &input) |
Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary). More... | |
void | update () |
Retrieves the configured value from the currently loaded config-file. More... | |
Private Member Functions | |
bool | callFunctionWithIndex (bool(ConfigValueContainer::*function)(unsigned int, const MultiType &), const std::string &input) |
Calls the given function with parsed index and the parsed argument from the input string. More... | |
void | init (ConfigFileType::Value type, Identifier *identifier, const std::string §ionname, const std::string &varname) |
Initializes the ConfigValueContainer with default values. More... | |
void | initValue (const MultiType &defvalue) |
Does some special initialization for single config-values. More... | |
void | initVector () |
Does some special initialization for vector config-values. More... | |
Private Attributes | |
bool | bAddedDescription_ |
True if a description was added. More... | |
bool | bContainerIsNew_ |
True if it's the first time getValue() gets called. More... | |
bool | bDoInitialCallback_ |
True if the callback should be called as soon as it gets created. More... | |
bool | bIsVector_ |
True if the container contains a std::vector. More... | |
ConfigValueCallbackBase * | callback_ |
A callback function to call after getValue if the value changed. More... | |
std::string | defvalueString_ |
The string of the default-value. More... | |
std::vector< std::string > | defvalueStringVector_ |
A vector, containg the strings of the default-values in case we're storing a vector. More... | |
LanguageEntryLabel | description_ |
The description. More... | |
Identifier * | identifier_ |
The identifier of the class. More... | |
std::string | sectionname_ |
The name of the class the variable belongs to. More... | |
ConfigFileType::Value | type_ |
The type of the corresponding config-file. More... | |
MultiType | value_ |
The value. More... | |
std::vector< MultiType > | valueVector_ |
A vector, containg the values in case we're storing a vector. More... | |
std::string | varname_ |
The name of the variable. More... | |
The ConfigValuecontainer contains all needed information about a configurable variable.
The ConfigValueContainer class contains all needed information about a configurable variable:
This is needed to assign the configured values to all newly created objects.
The container searches for the entry in the config file. If there is an entry, it parses the specified value and assigns it to the variable of the right type. If there is no entry, it adds the entry with the default-value to the section of the variables class. If there is no section, the section and the entry are added to the end of the config-file.
|
inline |
Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
type | The type of the corresponding config-file |
identifier | The identifier of the class the variable belongs to |
sectionname | Name of the section the configValue should be put in. |
varname | The name of the variable |
defvalue | The default-value |
value | Only needed do determine the right type. |
|
inline |
Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
type | The type of the corresponding config-file |
identifier | The identifier of the class the variable belongs to |
sectionname | Name of the section the configValue should be put in. |
varname | The name of the variable |
defvalue | The default-value |
value | Only needed do determine the right type. |
orxonox::ConfigValueContainer::~ConfigValueContainer | ( | ) |
Destructor: Deletes the callback object if necessary.
bool orxonox::ConfigValueContainer::add | ( | const MultiType & | input | ) |
Adds a new entry to the end of the vector.
input | The new entry |
|
inline |
Adds a callback function, that gets called after getValue() if the newly assigned value differs from the old value of the variable.
object | The object to call the function |
function | The callback function |
|
private |
Calls the given function with parsed index and the parsed argument from the input string.
function | The function to call |
input | The input string |
ConfigValueContainer & orxonox::ConfigValueContainer::description | ( | const std::string & | description | ) |
Adds a description to the config-value.
description | The description |
const std::string & orxonox::ConfigValueContainer::getDescription | ( | ) | const |
Returns the description of the config-value.
|
inline |
Returns the associated identifier (can be nullptr).
|
inline |
Returns the name of this container.
|
inline |
Returns the name of the section this config value is in.
|
inline |
Returns the typename of the assigned config-value.
|
inline |
Returns the configured value.
value | A pointer to the variable to store the value. |
object | The object calling this function |
|
inline |
Returns the configured vector.
value | A pointer to the vector to store the values. |
object | The object calling this function |
|
inline |
Returns the vectors size (or zero if it's not a vector).
|
private |
Initializes the ConfigValueContainer with default values.
Does some special initialization for single config-values.
|
private |
Does some special initialization for vector config-values.
|
inline |
Returns true if this config-value is a vector.
bool orxonox::ConfigValueContainer::remove | ( | unsigned int | index | ) |
Removes an existing entry from the vector.
index | The index of the entry |
bool orxonox::ConfigValueContainer::reset | ( | ) |
Sets the value of the variable back to the default value and resets the config-file entry.
bool orxonox::ConfigValueContainer::set | ( | const MultiType & | input | ) |
Assigns a new value to the config-value of all objects and writes the change into the config-file.
input | The new value |
bool orxonox::ConfigValueContainer::set | ( | unsigned int | index, |
const MultiType & | input | ||
) |
Assigns a new value to the config-value of all objects and writes the change into the config-file.
index | The index in the vector |
input | The new value |
|
inline |
Converts the config-value to a string.
bool orxonox::ConfigValueContainer::tset | ( | const MultiType & | input | ) |
Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary).
input | The new value. If bIsVector_ then write "index value" |
bool orxonox::ConfigValueContainer::tset | ( | unsigned int | index, |
const MultiType & | input | ||
) |
Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary).
index | The index in the vector |
input | The new value |
void orxonox::ConfigValueContainer::update | ( | ) |
Retrieves the configured value from the currently loaded config-file.
|
private |
True if a description was added.
|
private |
True if it's the first time getValue() gets called.
|
private |
True if the callback should be called as soon as it gets created.
|
private |
True if the container contains a std::vector.
|
private |
A callback function to call after getValue if the value changed.
|
private |
The string of the default-value.
|
private |
A vector, containg the strings of the default-values in case we're storing a vector.
|
private |
The description.
|
private |
The identifier of the class.
|
private |
The name of the class the variable belongs to.
|
private |
The type of the corresponding config-file.
|
private |
The value.
|
private |
A vector, containg the values in case we're storing a vector.
|
private |
The name of the variable.