orxonox::ConfigValueContainer Class Reference

The ConfigValuecontainer contains all needed informations about a configurable variable. More...

#include <src/core/ConfigValueContainer.h>

List of all members.

Public Member Functions

bool add (const MultiType &input)
 Adds a new entry to the end of the vector.
template<class T>
ConfigValueContainercallback (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.
template<class V>
 ConfigValueContainer (ConfigFileType type, Identifier *identifier, const std::string &sectionname, const std::string &varname, const std::vector< V > &defvalue)
 Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
template<class D, class V>
 ConfigValueContainer (ConfigFileType type, Identifier *identifier, const std::string &sectionname, 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.
ConfigValueContainerdescription (const std::string &description)
 Adds a description to the config-value.
const std::stringgetDescription () const
 Returns the description of the config-value.
const std::stringgetName () const
 Returns the name of this container.
const std::stringgetSectionName () const
 Retuns the name of the section this config value is in.
std::string getTypename () const
 Returns the typename of the assigned config-value.
template<typename T, class C>
ConfigValueContainergetValue (std::vector< T > *value, C *object)
 Returns the configured vector.
template<typename T, class C>
ConfigValueContainergetValue (T *value, C *object)
 Returns the configured value.
unsigned int getVectorSize () const
 Returns the vectors size (or zero if it's not a vector).
bool isVector () const
 Returns true if this config-value is a vector.
bool remove (unsigned int index)
 Removes an existing entry from the vector.
bool reset ()
 Sets the value of the variable back to the default value and resets the config-file entry.
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.
bool set (const MultiType &input)
 Assigns a new value to the config-value of all objects and writes the change into the config-file.
std::string toString () const
 Converts the config-value to a string.
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).
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).
void update ()
 Retrieves the configured value from the currently loaded config-file.
 ~ConfigValueContainer ()
 Destructor: Deletes the callback object if necessary.

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.
void init (ConfigFileType type, Identifier *identifier, const std::string &sectionname, const std::string &varname)
 Initializes the ConfigValueContainer with defaultvalues.
void initValue (const MultiType &defvalue)
 Does some special initialization for single config-values.
void initVector ()
 Does some special initialization for vector config-values.

Private Attributes

bool bAddedDescription_
 True if a description was added.
bool bContainerIsNew_
 True if it's the first time getValue() gets called.
bool bDoInitialCallback_
 True if the callback should be called as soon as it gets created.
bool bIsVector_
 True if the container contains a std::vector.
ConfigValueCallbackBasecallback_
 A callback function to call after getValue if the value changed.
std::string defvalueString_
 The string of the default-value.
std::vector< std::stringdefvalueStringVector_
 A vector, containg the strings of the default-values in case we're storing a vector.
LanguageEntryLabel description_
 The description.
Identifieridentifier_
 The identifier of the class.
std::string sectionname_
 The name of the class the variable belongs to.
ConfigFileType type_
 The type of the corresponding config-file.
MultiType value_
 The value.
std::vector< MultiTypevalueVector_
 A vector, containg the values in case we're storing a vector.
std::string varname_
 The name of the variable.


Detailed Description

The ConfigValuecontainer contains all needed informations about a configurable variable.

The ConfigValueContainer class contains all needed informations 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.


Constructor & Destructor Documentation

template<class D, class V>
orxonox::ConfigValueContainer::ConfigValueContainer ( ConfigFileType  type,
Identifier identifier,
const std::string sectionname,
const std::string varname,
const D &  defvalue,
const V &  value 
) [inline]

Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.

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

template<class V>
orxonox::ConfigValueContainer::ConfigValueContainer ( ConfigFileType  type,
Identifier identifier,
const std::string sectionname,
const std::string varname,
const std::vector< V > &  defvalue 
) [inline]

Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.

Parameters:
type The type of the corresponding config-file
identifier The identifier of the class the variable belongs to
varname The name of the variable
defvalue The default-value

References orxonox::KeyCode::V.

orxonox::ConfigValueContainer::~ConfigValueContainer (  ) 

Destructor: Deletes the callback object if necessary.

References callback_.


Member Function Documentation

bool orxonox::ConfigValueContainer::add ( const MultiType input  ) 

Adds a new entry to the end of the vector.

Parameters:
input The new entry
Returns:
True if the new entry was successfully added

References bIsVector_, COUT, sectionname_, valueVector_, and varname_.

template<class T>
ConfigValueContainer& orxonox::ConfigValueContainer::callback ( T *  object,
void(T::*)(void)  function 
) [inline]

Adds a callback function, that gets called after getValue() if the newly assigned value differs from the old value of the variable.

Parameters:
object The object to call the function
function The callback function

Referenced by orxonox::Button::readConfigValue().

bool orxonox::ConfigValueContainer::callFunctionWithIndex ( bool(ConfigValueContainer::*)(unsigned int, const MultiType &)  function,
const std::string input 
) [private]

Calls the given function with parsed index and the parsed argument from the input string.

Parameters:
function The function to call
input The input string
Returns:
The returnvalue of the functioncall

References orxonox::convertValue(), COUT, orxonox::SubString::join(), orxonox::MAX_VECTOR_INDEX, sectionname_, orxonox::SubString::size(), orxonox::SubString::subSet(), varname_, and orxonox::SubString::WhiteSpaces.

Referenced by set(), and tset().

ConfigValueContainer & orxonox::ConfigValueContainer::description ( const std::string description  ) 

Adds a description to the config-value.

Parameters:
description The description

References AddLanguageEntry, bAddedDescription_, description_, sectionname_, and varname_.

const std::string & orxonox::ConfigValueContainer::getDescription (  )  const

Returns the description of the config-value.

Returns:
The description

References description_, and GetLocalisation.

const std::string& orxonox::ConfigValueContainer::getName (  )  const [inline]

Returns the name of this container.

const std::string& orxonox::ConfigValueContainer::getSectionName (  )  const [inline]

Retuns the name of the section this config value is in.

std::string orxonox::ConfigValueContainer::getTypename (  )  const [inline]

Returns the typename of the assigned config-value.

Returns:
The typename

template<typename T, class C>
ConfigValueContainer& orxonox::ConfigValueContainer::getValue ( std::vector< T > *  value,
C *  object 
) [inline]

Returns the configured vector.

Parameters:
value A pointer to the vector to store the values.
object The object calling this function
Returns:
The ConfigValueContainer

template<typename T, class C>
ConfigValueContainer& orxonox::ConfigValueContainer::getValue ( T *  value,
C *  object 
) [inline]

Returns the configured value.

Parameters:
value A pointer to the variable to store the value.
object The object calling this function
Returns:
The ConfigValueContainer

References orxonox::KeyCode::T.

Referenced by orxonox::Button::readConfigValue().

unsigned int orxonox::ConfigValueContainer::getVectorSize (  )  const [inline]

Returns the vectors size (or zero if it's not a vector).

void orxonox::ConfigValueContainer::init ( ConfigFileType  type,
Identifier identifier,
const std::string sectionname,
const std::string varname 
) [private]

void orxonox::ConfigValueContainer::initValue ( const MultiType defvalue  )  [private]

Does some special initialization for single config-values.

References bIsVector_, defvalueString_, orxonox::MultiType::getString(), update(), and value_.

void orxonox::ConfigValueContainer::initVector (  )  [private]

bool orxonox::ConfigValueContainer::isVector (  )  const [inline]

Returns true if this config-value is a vector.

bool orxonox::ConfigValueContainer::remove ( unsigned int  index  ) 

Removes an existing entry from the vector.

Parameters:
index The index of the entry
Returns:
True if the entry was removed

References bIsVector_, COUT, orxonox::ConfigFileManager::deleteVectorEntries(), orxonox::ConfigFileManager::getInstance(), orxonox::MultiType::isType(), sectionname_, orxonox::ConfigFileManager::setValue(), orxonox::MT_Type::String, type_, value_, valueVector_, and varname_.

bool orxonox::ConfigValueContainer::reset (  ) 

Sets the value of the variable back to the default value and resets the config-file entry.

References bIsVector_, defvalueString_, defvalueStringVector_, orxonox::ConfigFileManager::deleteVectorEntries(), orxonox::ConfigFileManager::getInstance(), sectionname_, type_, and varname_.

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.

Parameters:
index The index in the vector
input The new value
Returns:
True if the new value was successfully assigned

References bIsVector_, COUT, orxonox::ConfigFileManager::getInstance(), orxonox::MultiType::isType(), sectionname_, orxonox::ConfigFileManager::setValue(), orxonox::MT_Type::String, tset(), type_, value_, and varname_.

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.

Parameters:
input The new value
Returns:
True if the new value was successfully assigned

References bIsVector_, callFunctionWithIndex(), orxonox::ConfigFileManager::getInstance(), orxonox::MultiType::isType(), sectionname_, orxonox::ConfigFileManager::setValue(), orxonox::MT_Type::String, tset(), type_, value_, and varname_.

std::string orxonox::ConfigValueContainer::toString (  )  const [inline]

Converts the config-value to a string.

Returns:
The string

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

Parameters:
index The index in the vector
input The new value
Returns:
True if the new value was successfully assigned

References bIsVector_, COUT, identifier_, orxonox::MAX_VECTOR_INDEX, sectionname_, orxonox::Identifier::updateConfigValues(), valueVector_, and varname_.

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

Parameters:
input The new value. If bIsVector_ then write "index value"
Returns:
True if the new value was successfully assigned

References bIsVector_, callFunctionWithIndex(), identifier_, orxonox::Identifier::updateConfigValues(), and value_.

Referenced by set().

void orxonox::ConfigValueContainer::update (  ) 


Member Data Documentation

True if a description was added.

Referenced by description(), and init().

True if it's the first time getValue() gets called.

Referenced by init().

True if the callback should be called as soon as it gets created.

Referenced by init().

True if the container contains a std::vector.

Referenced by add(), initValue(), initVector(), remove(), reset(), set(), tset(), and update().

A callback function to call after getValue if the value changed.

Referenced by init(), and ~ConfigValueContainer().

The string of the default-value.

Referenced by initValue(), reset(), and update().

A vector, containg the strings of the default-values in case we're storing a vector.

Referenced by initVector(), reset(), and update().

The description.

Referenced by description(), and getDescription().

The identifier of the class.

Referenced by init(), and tset().

The name of the class the variable belongs to.

Referenced by add(), callFunctionWithIndex(), description(), init(), initVector(), remove(), reset(), set(), tset(), and update().

The type of the corresponding config-file.

Referenced by init(), initVector(), remove(), reset(), set(), and update().

The value.

Referenced by initValue(), initVector(), remove(), set(), tset(), and update().

A vector, containg the values in case we're storing a vector.

Referenced by add(), initVector(), remove(), tset(), and update().

The name of the variable.

Referenced by add(), callFunctionWithIndex(), description(), init(), initVector(), remove(), reset(), set(), tset(), and update().


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

Generated on Tue Jul 28 16:22:25 2009 for Orxonox by  doxygen 1.5.6