MachineIntelligenceCore:Toolchain
|
Server of application parameters - defined in the form of a singleton, with double-checked locking pattern (DCLP) based access to instance. More...
#include <ParameterServer.hpp>
Public Member Functions | |
void | print (boost::property_tree::ptree const &pt) |
const boost::property_tree::ptree & | returnNode (std::string node_name_) |
void | registerPropertyTree (mic::configuration::PropertyTree *pt_) |
boost::program_options::options_description & | getProgramOptions () |
const boost::program_options::variables_map & | getProgramArguments () |
void | parseApplicationParameters (int argc, char *argv[]) |
void | loadPropertiesFromConfiguration () |
void | initializePropertyDependentVariables () |
int | getArgc () |
char ** | getArgv () |
std::string | getAppName () |
Static Public Member Functions | |
static ParameterServer * | getInstance () |
Private Member Functions | |
ParameterServer () | |
Private Attributes | |
boost::property_tree::ptree | config_tree |
boost::program_options::options_description | program_options |
boost::program_options::variables_map | program_arguments |
std::map< std::string, mic::configuration::PropertyTree * > | property_trees_registry |
int | argc |
Number of application parameters. More... | |
char ** | argv |
Array of application parameters. More... | |
std::string | application_name |
Name of the executed binary file. More... | |
Static Private Attributes | |
static boost::atomic < ParameterServer * > | instance_ |
static boost::mutex | instantiation_mutex |
Server of application parameters - defined in the form of a singleton, with double-checked locking pattern (DCLP) based access to instance.
Definition at line 58 of file ParameterServer.hpp.
|
private |
Provate constructor.
Definition at line 68 of file ParameterServer.cpp.
Referenced by getInstance().
|
inline |
Returns application name.
Definition at line 128 of file ParameterServer.hpp.
|
inline |
Returns number of application parameters.
Definition at line 118 of file ParameterServer.hpp.
|
inline |
Returns application parameters.
Definition at line 123 of file ParameterServer.hpp.
|
static |
Method for accessing the object instance, with double-checked locking optimization.
Definition at line 48 of file ParameterServer.cpp.
References instance_, instantiation_mutex, and ParameterServer().
const boost::program_options::variables_map & mic::configuration::ParameterServer::getProgramArguments | ( | ) |
Returns program arguments.
Definition at line 240 of file ParameterServer.cpp.
References program_arguments.
boost::program_options::options_description & mic::configuration::ParameterServer::getProgramOptions | ( | ) |
Returns program options.
Definition at line 236 of file ParameterServer.cpp.
References program_options.
void mic::configuration::ParameterServer::initializePropertyDependentVariables | ( | ) |
Initilizes variables of all registered property trees.
Definition at line 221 of file ParameterServer.cpp.
References LINFO, LOG, LSTATUS, and property_trees_registry.
void mic::configuration::ParameterServer::loadPropertiesFromConfiguration | ( | ) |
Loads the properties from configuration. For each main node of the loaded configuration file it tries to find the corresponding "registered property tree", and if succeed - loads its properties.
Definition at line 196 of file ParameterServer.cpp.
References config_tree, LERROR, LINFO, LOG, LSTATUS, and property_trees_registry.
void mic::configuration::ParameterServer::parseApplicationParameters | ( | int | argc, |
char * | argv[] | ||
) |
Method parses (and stores) the application parameters.
argc | Number of application parameters. |
argv | Array of application parameters. |
Definition at line 100 of file ParameterServer.cpp.
References application_name, config_tree, LERROR, LINFO, LOG, LOGGER, LSTATUS, print(), and program_options.
void mic::configuration::ParameterServer::print | ( | boost::property_tree::ptree const & | pt | ) |
Prints the tree - a recursive function.
pt | A property tree object (config_tree as default). |
Definition at line 74 of file ParameterServer.cpp.
Referenced by parseApplicationParameters().
void mic::configuration::ParameterServer::registerPropertyTree | ( | mic::configuration::PropertyTree * | pt_ | ) |
Adds the property tree to the registry.
pt_ | Pointer to the registered property tree object. |
Definition at line 188 of file ParameterServer.cpp.
References mic::configuration::PropertyTree::getNodeName(), LDEBUG, LOG, and property_trees_registry.
const boost::property_tree::ptree & mic::configuration::ParameterServer::returnNode | ( | std::string | node_name_ | ) |
Returns property tree of a node of given name. Returns nullptr if not found.
node_name_ | Name of the node. |
Definition at line 84 of file ParameterServer.cpp.
References config_tree, LINFO, LOG, and LWARNING.
|
private |
Name of the executed binary file.
Definition at line 183 of file ParameterServer.hpp.
Referenced by parseApplicationParameters().
|
private |
Number of application parameters.
Definition at line 177 of file ParameterServer.hpp.
|
private |
Array of application parameters.
Definition at line 180 of file ParameterServer.hpp.
|
private |
Property tree.
Definition at line 151 of file ParameterServer.hpp.
Referenced by loadPropertiesFromConfiguration(), parseApplicationParameters(), and returnNode().
|
staticprivate |
Private instance - accessed as atomic operation.
Definition at line 134 of file ParameterServer.hpp.
Referenced by getInstance().
|
staticprivate |
Mutex used for instantiation of the instance.
Definition at line 139 of file ParameterServer.hpp.
Referenced by getInstance().
|
private |
! The program_arguments holds the actual command line arguments received. This variable takes value only after parseApplicationArguments(). Note that before that call, an application may call getProgramOptions() and extend the set of allowed command line arguments with new command line options; then call getProgramArguments to obtain their actual values.
Definition at line 168 of file ParameterServer.hpp.
Referenced by getProgramArguments().
|
private |
Program options, to parse command line arguments. This gets populated by default with a few arguments (like "help") and applications can add additional options by accessing this field via getProgramOptions()
Definition at line 158 of file ParameterServer.hpp.
Referenced by getProgramOptions(), and parseApplicationParameters().
|
private |
Vector of registered property trees.
Definition at line 173 of file ParameterServer.hpp.
Referenced by initializePropertyDependentVariables(), loadPropertiesFromConfiguration(), and registerPropertyTree().