MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ParameterServer.hpp
Go to the documentation of this file.
1 
23 #ifndef SRC_CONFIGURATION_PARAMETERSERVER_HPP_
24 #define SRC_CONFIGURATION_PARAMETERSERVER_HPP_
25 
26 #include <boost/atomic.hpp>
27 #include <boost/thread/mutex.hpp>
28 #include <boost/program_options.hpp>
29 
30 #include <logger/Log.hpp>
31 using namespace mic::logger;
32 
34 
35 
36 namespace mic {
37 namespace configuration {
38 
43 typedef std::pair<std::string, mic::configuration::PropertyTree*> id_pt_pair_t;
44 
45 
50 typedef std::map<std::string, mic::configuration::PropertyTree*>::iterator id_pt_it_t;
51 
52 
53 
59 public:
64  static ParameterServer* getInstance();
65 
70  void print(boost::property_tree::ptree const& pt);
71 
77  const boost::property_tree::ptree & returnNode(std::string node_name_);
78 
79 
84  void registerPropertyTree(mic::configuration::PropertyTree* pt_);
85 
86 
90  boost::program_options::options_description &getProgramOptions();
91 
95  const boost::program_options::variables_map &getProgramArguments();
96 
102  void parseApplicationParameters(int argc, char* argv[]);
103 
107  void loadPropertiesFromConfiguration();
108 
112  void initializePropertyDependentVariables();
113 
114 
118  int getArgc() { return argc; }
119 
123  char ** getArgv() {return argv; }
124 
128  std::string getAppName() { return application_name; }
129 
130 private:
134  static boost::atomic<ParameterServer*> instance_;
135 
139  static boost::mutex instantiation_mutex;
140 
144  ParameterServer();
145 
146  //virtual ~ParameterServer();
147 
151  boost::property_tree::ptree config_tree;
152 
158  boost::program_options::options_description program_options;
159 
160 
168  boost::program_options::variables_map program_arguments;
169 
173  std::map<std::string, mic::configuration::PropertyTree*> property_trees_registry;
174 
175 
177  int argc;
178 
180  char** argv;
181 
183  std::string application_name;
184 
185 };
186 
187 
192 #define PARAM_SERVER mic::configuration::ParameterServer::getInstance()
193 
194 } /* namespace configuration */
195 } /* namespace mic */
196 
197 #endif /* SRC_CONFIGURATION_PARAMETERSERVER_HPP_ */
Contains declaration of the PropertyTree class.
Parent class for all classes possessing properties. Contains methods useful for their management...
Contains definitions of main logger-related macros.
std::string application_name
Name of the executed binary file.
std::pair< std::string, mic::configuration::PropertyTree * > id_pt_pair_t
Type used in adding property trees to registry.
Server of application parameters - defined in the form of a singleton, with double-checked locking pa...
std::map< std::string, mic::configuration::PropertyTree * >::iterator id_pt_it_t
Type used during iterating/searching for property trees in registry.
char ** argv
Array of application parameters.
static boost::atomic< ParameterServer * > instance_
boost::program_options::options_description program_options
boost::program_options::variables_map program_arguments
boost::property_tree::ptree config_tree
std::map< std::string, mic::configuration::PropertyTree * > property_trees_registry
int argc
Number of application parameters.