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 ConfigurationgetInstance ()
 returns a reference to the only configuration instance More...
 

Friends

class std::auto_ptr< Configuration >
 

Detailed Description

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.

Member Function Documentation

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

Parameters
[in]pathpath to the configuration value
[in]namename of the setting
[in]valuevalue 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

Parameters
[in]pathpath to the configuration value
[in]namename of the setting
[in]valuevalue 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"

Parameters
[in]pathpath to the configuration value
Returns
true if the value is defined otherwise false.
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.

Parameters
[in]pathpath to the configuration value
Returns
bool 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.

Parameters
[in]pathpath to the configuration value
Returns
double configuration value
Configuration & Configuration::getInstance ( )
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.

Returns
reference to the only configuration instance
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.

Parameters
[in]pathpath to the configuration value
Returns
integer 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.

Parameters
[in]pathpath to the configuration value
Returns
string configuration value
libconfig::Setting& config::Configuration::lookup ( const std::string  path) const
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.

Parameters
[in]pathpath to the configuration value
Returns
reference to a Setting object
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++.

Parameters
[in]configFilepath to the configuration file

The documentation for this class was generated from the following files:
  • /home/chris/Development/Release/NanoStructures/config/configuration.h
  • /home/chris/Development/Release/NanoStructures/config/configuration.cpp