A more user-friendly API for the ConfigDB. More...
#include <Robots/LoBot/config/LoConfig.H>
Public Member Functions | |
template<> | |
bool | get (const std::string §ion, const std::string &key, const bool &default_value) |
Static Public Member Functions | |
static void | load (const std::string &config_file) |
static void | set (const std::string §ion, const std::string &key, const std::string &value) |
static void | set_global (const std::string &key, const std::string &value) |
static void | set_internal (const std::string &key, const std::string &value) |
template<typename T > | |
static T | get (const std::string §ion, const std::string &key, const T &default_value=T()) |
template<typename T > | |
static void | get (const std::string §ion, const std::string &key, T *target, const T *defaults, unsigned int n) |
template<typename T > | |
static T | get_global (const std::string &key, const T &defval=T()) |
static void | dump () |
Development and debugging support. |
A more user-friendly API for the ConfigDB.
lobot::ConfigDB is an "internal" class related to the lobot config system and is not meant to be used directly by other objects in the lobot system. Instead, client modules should use the API provided by this class for loading and retrieving configuration settings.
Definition at line 160 of file LoConfig.H.
void lobot::Configuration::dump | ( | ) | [static] |
Development and debugging support.
Definition at line 155 of file LoConfig.C.
bool lobot::Configuration::get | ( | const std::string & | section, | |
const std::string & | key, | |||
const bool & | default_value | |||
) | [inline] |
Partial specialization of above method for retrieving on/off/yes/no flags from the config file.
Definition at line 230 of file LoConfig.H.
void lobot::Configuration::get | ( | const std::string & | section, | |
const std::string & | key, | |||
T * | target, | |||
const T * | defaults, | |||
unsigned int | n | |||
) | [inline, static] |
The configuration database simply retains key-value pairs as strings. But some settings can be lists (e.g., the value corresponding to some key may be a list of numbers). This method "breaks up" the value portion of the specified key and section into a list and returns the result via an array of type T.
Retrieve the values corresponding to the specified key from the specified section of the config file and return them via an array of type T.
Definition at line 247 of file LoConfig.H.
T lobot::Configuration::get | ( | const std::string & | section, | |
const std::string & | key, | |||
const T & | default_value = T() | |||
) | [inline, static] |
This method retrieves the value corresponding to the specified key from the specified section of the configuration database. If the key is not defined, the default value supplied by the client will be returned.
Retrieve the value corresponding to the specified key from the specified section of the config file and return it as an instance of type T.
Definition at line 218 of file LoConfig.H.
T lobot::Configuration::get_global | ( | const std::string & | key, | |
const T & | defval = T() | |||
) | [inline, static] |
This method retrieves the value corresponding to the specified key from the unnamed/anonymous global/top-level scope section of the configuration database. If the key is not defined in the top-level section, the default value supplied by the client will be returned.
Definition at line 262 of file LoConfig.H.
void lobot::Configuration::load | ( | const std::string & | config_file | ) | [static] |
This method loads the configuration settings from the specified file.
Definition at line 68 of file LoConfig.C.
Referenced by lobot::App::run().
void lobot::Configuration::set | ( | const std::string & | section, | |
const std::string & | key, | |||
const std::string & | value | |||
) | [static] |
This method inserts the supplied key-value pair into the specified section of the configuration database.
Definition at line 99 of file LoConfig.C.
void lobot::Configuration::set_global | ( | const std::string & | key, | |
const std::string & | value | |||
) | [static] |
This method inserts the supplied key-value pair into the unnamed/anonymous global/top-level scope of the configuration database.
Definition at line 105 of file LoConfig.C.
void lobot::Configuration::set_internal | ( | const std::string & | key, | |
const std::string & | value | |||
) | [static] |
This method inserts the supplied key-value pair into the (secret) internal section of the configuration database.
Definition at line 110 of file LoConfig.C.
References LOCD_INTERNAL.
Referenced by lobot::App::run().