NanoStructures  1.0
DMFT solver for layered, strongly correlated nanostructures
configuration.h
Go to the documentation of this file.
1 /*
2  * File: Configuration.h
3  * Author: chris
4  *
5  * Created on January 2, 2012, 2:32 PM
6  */
7 
8 #ifndef CONFIGURATION_H
9 #define CONFIGURATION_H
10 
23 /*
24  * Copyright (c) 2014 Christoph Schuette.
25  *
26  * The license and distribution terms for this file may be
27  * found in the file LICENSE in this distribution
28  */
29 
30 #include <libconfig.h++>
31 #include <string>
32 #include <list>
33 #include <memory>
34 #include <vector>
35 #include <utility>
36 
37 namespace config {
38 
46  class Configuration {
47  public:
57  static Configuration& getInstance();
58  friend class std::auto_ptr<Configuration>;
59 
68  void readFile(std::string configFile);
69 
82  bool exists(std::string path);
83 
93  double getDouble(std::string path);
94 
104  bool getBool(std::string path);
105 
115  int getInteger(std::string path);
116 
126  std::string getString(std::string path);
127 
136  void addSetting(std::string path, std::string name, std::string value);
137 
146  void editSetting(std::string path, std::string name, double value);
147 
157  inline libconfig::Setting& lookup(const std::string path) const {
158  return m_configuration.lookup(path);
159  }
160 
161  std::string getName() const {
162  return "Configuration";
163  }
164 
165  private:
166  //private constructor and destructor
167  Configuration();
168  virtual ~Configuration();
169 
170  static std::auto_ptr<Configuration> m_instancePtr;
171 
172  //config object
173  libconfig::Config m_configuration;
174 
175  };
176 }
177 #endif /* CONFIGURATION_H */
178 
void readFile(std::string configFile)
parses configuration file configFile and loads the data into object. The configuration file needs to ...
Definition: configuration.cpp:34
bool getBool(std::string path)
retrieves the configuration value found at a given configuration path.
Definition: configuration.cpp:58
libconfig::Setting & lookup(const std::string path) const
retrieves the configuration value found at a given configuration path as a reference to a libconfig::...
Definition: configuration.h:157
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 ...
Definition: configuration.cpp:38
double getDouble(std::string path)
retrieves the configuration value found at a given configuration path.
Definition: configuration.cpp:54
bool exists(std::string path)
determines whether a given configuration value exists.
Definition: configuration.cpp:29
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 ...
Definition: configuration.cpp:44
std::string getString(std::string path)
retrieves the configuration value found at a given configuration path.
Definition: configuration.cpp:66
int getInteger(std::string path)
retrieves the configuration value found at a given configuration path.
Definition: configuration.cpp:62
A configuration object which is populated from a configuration file and allows to query and modify co...
Definition: configuration.h:46
static Configuration & getInstance()
returns a reference to the only configuration instance
Definition: configuration.cpp:18