MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mic::configuration::ParameterServer Class Reference

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>

Collaboration diagram for mic::configuration::ParameterServer:

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 ParameterServergetInstance ()
 

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
 

Detailed Description

Server of application parameters - defined in the form of a singleton, with double-checked locking pattern (DCLP) based access to instance.

Author
tkornuta

Definition at line 58 of file ParameterServer.hpp.

Constructor & Destructor Documentation

mic::configuration::ParameterServer::ParameterServer ( )
private

Provate constructor.

Definition at line 68 of file ParameterServer.cpp.

Referenced by getInstance().

Member Function Documentation

std::string mic::configuration::ParameterServer::getAppName ( )
inline

Returns application name.

Definition at line 128 of file ParameterServer.hpp.

int mic::configuration::ParameterServer::getArgc ( )
inline

Returns number of application parameters.

Definition at line 118 of file ParameterServer.hpp.

char** mic::configuration::ParameterServer::getArgv ( )
inline

Returns application parameters.

Definition at line 123 of file ParameterServer.hpp.

ParameterServer * mic::configuration::ParameterServer::getInstance ( )
static

Method for accessing the object instance, with double-checked locking optimization.

Returns
Instance of ApplicationState singleton.

Definition at line 48 of file ParameterServer.cpp.

References instance_, instantiation_mutex, and ParameterServer().

Here is the call graph for this function:

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.

Parameters
argcNumber of application parameters.
argvArray 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.

Here is the call graph for this function:

void mic::configuration::ParameterServer::print ( boost::property_tree::ptree const &  pt)

Prints the tree - a recursive function.

Parameters
ptA property tree object (config_tree as default).

Definition at line 74 of file ParameterServer.cpp.

References LDEBUG, and LOG.

Referenced by parseApplicationParameters().

void mic::configuration::ParameterServer::registerPropertyTree ( mic::configuration::PropertyTree pt_)

Adds the property tree to the registry.

Parameters
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.

Here is the call graph for this function:

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.

Parameters
node_name_Name of the node.
Returns
Property tree of a found node, nullptr otherwise.

Definition at line 84 of file ParameterServer.cpp.

References config_tree, LINFO, LOG, and LWARNING.

Member Data Documentation

std::string mic::configuration::ParameterServer::application_name
private

Name of the executed binary file.

Definition at line 183 of file ParameterServer.hpp.

Referenced by parseApplicationParameters().

int mic::configuration::ParameterServer::argc
private

Number of application parameters.

Definition at line 177 of file ParameterServer.hpp.

char** mic::configuration::ParameterServer::argv
private

Array of application parameters.

Definition at line 180 of file ParameterServer.hpp.

boost::property_tree::ptree mic::configuration::ParameterServer::config_tree
private
boost::atomic< ParameterServer * > mic::configuration::ParameterServer::instance_
staticprivate

Private instance - accessed as atomic operation.

Definition at line 134 of file ParameterServer.hpp.

Referenced by getInstance().

boost::mutex mic::configuration::ParameterServer::instantiation_mutex
staticprivate

Mutex used for instantiation of the instance.

Definition at line 139 of file ParameterServer.hpp.

Referenced by getInstance().

boost::program_options::variables_map mic::configuration::ParameterServer::program_arguments
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().

boost::program_options::options_description mic::configuration::ParameterServer::program_options
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().

std::map<std::string, mic::configuration::PropertyTree*> mic::configuration::ParameterServer::property_trees_registry
private

Vector of registered property trees.

Definition at line 173 of file ParameterServer.hpp.

Referenced by initializePropertyDependentVariables(), loadPropertiesFromConfiguration(), and registerPropertyTree().


The documentation for this class was generated from the following files: