|
rad
4.0.0
|
#include <config.hpp>
Public Member Functions | |
| Config () | |
| virtual | ~Config () |
| const elt::configng::CiiConfigDocument & | GetConfigDoc () |
| bool | ParseOptionsAndLoad (int argc, char *argv[]) |
| void | LoadConfig (const std::string &filename="") |
| void | ConfigureLogging (const std::string &filename="") |
| void | MergeConfig (const elt::configng::CiiConfigDocument &cfg_doc) |
| std::string | ConvertKey (const std::string &key, const char src_separator, const char dst_separator) |
| template<typename T > | |
| T | GetParam (const std::string &key, const char separator=KEY_SEPARATOR_OLDB) |
| template<typename T > | |
| void | SetParam (const std::string &key, const T &value, const char separator=KEY_SEPARATOR_OLDB) |
| template<typename T > | |
| void | AddParam (const std::string &key, const T &value, const char separator=KEY_SEPARATOR_OLDB) |
| void | CreateDefaultConfig () |
| void | CreateDefaultConfig (const std::string &default_cfg) |
| std::string | PrintNode (const elt::configng::CiiConfigInstanceNode &node, const std::string &indentation) |
| std::string | Print (const elt::configng::CiiConfigInstanceNamespace &instances) |
| std::string | Print () |
| Config (const Config &)=delete | |
| Config & | operator= (const Config &)=delete |
| Disable copy constructor. More... | |
This class provide access to the command line options and the configuration parameters stored in the configuration file.
| exciiserver::Config::Config | ( | ) |
Default constructor.
Initialize application configuration attributes by
|
virtual |
Default destructor.
|
delete |
| void exciiserver::Config::AddParam | ( | const std::string & | key, |
| const T & | value, | ||
| const char | separator = KEY_SEPARATOR_OLDB |
||
| ) |
Add a configuration parameter to the stream which will be used to create the initial CiiConfigDocument.
| void exciiserver::Config::ConfigureLogging | ( | const std::string & | filename = "" | ) |
This method load from a log.properties file the logging configuration and it apply it.
If no filename is passed, it uses the one defined in the application configuration file.
| [in] | filename | Log properties filename. |
| std::string exciiserver::Config::ConvertKey | ( | const std::string & | key, |
| const char | src_separator, | ||
| const char | dst_separator | ||
| ) |
Utility to replace separators in a key. E.g.: from CII OLDB URI '/' separator to YAML '.' or vice-versa to be able to dump the configuration to the OLDB.
| key | Key to convert using a src separator. |
| src_separator | Separator used in the given key. |
| dst_separator | Separator to be used in the returned key. |
| void exciiserver::Config::CreateDefaultConfig | ( | ) |
Create the initial applications configuration (CiiConfigDocument) from the stream, containing all configuration parameters initialized with default values.
| void exciiserver::Config::CreateDefaultConfig | ( | const std::string & | default_cfg | ) |
|
inline |
| T exciiserver::Config::GetParam | ( | const std::string & | key, |
| const char | separator = KEY_SEPARATOR_OLDB |
||
| ) |
Return the value associated to a configuration parameter.
| key | Identifier of the configuration parameter in OLDB format. |
| separator | Key separator character, e.g. '.' for CFG, '/' for OLDB. |
| void exciiserver::Config::LoadConfig | ( | const std::string & | filename = "" | ) |
This method load from a configuration file the application configuration overriding the initialization done in the constructor and the command line options.
| [in] | filename | Application configuration filename. |
| void exciiserver::Config::MergeConfig | ( | const elt::configng::CiiConfigDocument & | cfg_doc | ) |
This method merges the given configuration (e.g. loaded from file or string) with the one stored in this class. This method could be provided by CII.
| [in] | config_node | Configuration to merge into the current one. |
| bool exciiserver::Config::ParseOptionsAndLoad | ( | int | argc, |
| char * | argv[] | ||
| ) |
This method parses the command line parameters overriding the initialization done in the constructor.
| [in] | argc | Number of command line options. |
| [in] | argv | Pointer to the array of command line options. |
| std::string exciiserver::Config::Print | ( | ) |
Helper method to print the current application configuration.
| std::string exciiserver::Config::Print | ( | const elt::configng::CiiConfigInstanceNamespace & | instances | ) |
Helper method to print a CII configuration. TODO this should be provided by CII via << operator.
| std::string exciiserver::Config::PrintNode | ( | const elt::configng::CiiConfigInstanceNode & | node, |
| const std::string & | indentation | ||
| ) |
Helper method to print a CII configuration node. TODO this should be provided by CII via << operator.
| void exciiserver::Config::SetParam | ( | const std::string & | key, |
| const T & | value, | ||
| const char | separator = KEY_SEPARATOR_OLDB |
||
| ) |
Set the value of a configuration parameter.
| key | Identifier of the configuration parameter in OLDB format. |
| value | The value of a configuration parameter. |
| separator | Key separator character, e.g. '.' for CFG, '/' for OLDB. |