![]() |
NanoStructures
1.0
DMFT solver for layered, strongly correlated nanostructures
|
A configuration object which is populated from a configuration file and allows to query and modify configuration values. More...
#include <configuration.h>
Public Member Functions | |
void | readFile (std::string configFile) |
parses configuration file configFile and loads the data into object. The configuration file needs to written in the libconfig++ format, see libconfig++. More... | |
bool | exists (std::string path) |
determines whether a given configuration value exists. More... | |
double | getDouble (std::string path) |
retrieves the configuration value found at a given configuration path. More... | |
bool | getBool (std::string path) |
retrieves the configuration value found at a given configuration path. More... | |
int | getInteger (std::string path) |
retrieves the configuration value found at a given configuration path. More... | |
std::string | getString (std::string path) |
retrieves the configuration value found at a given configuration path. More... | |
void | addSetting (std::string path, std::string name, std::string value) |
adds the string setting named name to the configuration tree at path with the value value More... | |
void | editSetting (std::string path, std::string name, double value) |
modifies the string setting named name to the configuration tree at path with the value value More... | |
libconfig::Setting & | lookup (const std::string path) const |
retrieves the configuration value found at a given configuration path as a reference to a libconfig::Setting object. libconfig::Setting objects support automatic conversion to most common data types. More... | |
std::string | getName () const |
Static Public Member Functions | |
static Configuration & | getInstance () |
returns a reference to the only configuration instance More... |
Friends | |
class | std::auto_ptr< Configuration > |
A configuration object which is populated from a configuration file and allows to query and modify configuration values.
Essentially this class is just a front-end for the libconfig++ library. For convenience the configuration is a singleton object.
void Configuration::addSetting | ( | std::string | path, |
std::string | name, | ||
std::string | value | ||
) |
adds the string setting named name to the configuration tree at path with the value value
[in] | path | path to the configuration value |
[in] | name | name of the setting |
[in] | value | value of the setting |
void Configuration::editSetting | ( | std::string | path, |
std::string | name, | ||
double | value | ||
) |
modifies the string setting named name to the configuration tree at path with the value value
[in] | path | path to the configuration value |
[in] | name | name of the setting |
[in] | value | value of the setting |
bool Configuration::exists | ( | std::string | path | ) |
determines whether a given configuration value exists.
Libconfig++ configuration files have the structure of a tree, as they support groups of configuration values which themselves can be elements. A path to a configuration value within this tree uses a . as the separator.
example: "group1.nestedgroupA.value"
[in] | path | path to the configuration value |
bool Configuration::getBool | ( | std::string | path | ) |
retrieves the configuration value found at a given configuration path.
If the lookup fails the function throws a SettingNotFoundException exception.
[in] | path | path to the configuration value |
double Configuration::getDouble | ( | std::string | path | ) |
retrieves the configuration value found at a given configuration path.
If the lookup fails the function throws a SettingNotFoundException exception.
[in] | path | path to the configuration value |
|
static |
returns a reference to the only configuration instance
If the configuration has not been accessed previously an instance is created. The auto_ptr ensures that the object is properly destructed when the the application closes.
int Configuration::getInteger | ( | std::string | path | ) |
retrieves the configuration value found at a given configuration path.
If the lookup fails the function throws a SettingNotFoundException exception.
[in] | path | path to the configuration value |
std::string Configuration::getString | ( | std::string | path | ) |
retrieves the configuration value found at a given configuration path.
If the lookup fails the function throws a SettingNotFoundException exception.
[in] | path | path to the configuration value |
|
inline |
retrieves the configuration value found at a given configuration path as a reference to a libconfig::Setting object. libconfig::Setting objects support automatic conversion to most common data types.
[in] | path | path to the configuration value |
void Configuration::readFile | ( | std::string | configFile | ) |
parses configuration file configFile and loads the data into object. The configuration file needs to written in the libconfig++ format, see libconfig++.
[in] | configFile | path to the configuration file |