|
rad
5.2.0
|
#include <config.hpp>
Public Member Functions | |
| Config (const std::string &name=LOGGER_NAME, const std::string &log_level="ERROR") | |
| virtual | ~Config () |
| const elt::configng::CiiConfigDocument & | GetConfigDoc () |
| bpo::options_description & | GetOptionsDesc () |
| bpo::variables_map & | GetOptionsMap () |
| virtual bool | ParseOptions (int argc, char *argv[]) |
| virtual void | LoadConfig (const std::string &filename="") |
| virtual void | ConfigureLogging (const std::string &filename="") |
| virtual void | ApplyCmdLineOptions () |
| void | MergeConfig (const elt::configng::CiiConfigDocument &cfg_doc) |
| void | CreateDefaultConfig (const std::string &default_cfg) |
| template<typename T > | |
| void | AddParam (const std::string &key, const T &value) |
| bool | HasParam (const std::string &key) const |
| template<typename T > | |
| T | GetParam (const std::string &key) const |
| template<typename T > | |
| void | SetParam (const std::string &key, const T &value) |
| const std::string | GetConfigAsString () const |
| std::vector< std::string > | SetConfigAsString (const std::string &config) |
| 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.
|
explicit |
Default constructor.
Initialize application configuration attributes by
| name | Module name used for the default log filename and default logger name. |
| log_level | startup log level for the root logger. |
|
virtual |
Default destructor.
Reimplemented in rad::utest::Config, and exciiserver::Config.
|
delete |
| void rad::Config::AddParam | ( | const std::string & | key, |
| const T & | value | ||
| ) |
Add a configuration parameter to the stream which will be used to create the initial CiiConfigDocument.
| key | Fully qualified key (e.g. 'cfg.version'). |
| value | Value associated to the key. |
|
virtual |
This method override the configuration loaded from file by re-applying the command line options.
|
virtual |
This method load from a log.properties file the logging configuration and it applies it.
If no filename is passed, it uses the one defined in the application configuration file.
| [in] | filename | Log properties filename. |
| void rad::Config::CreateDefaultConfig | ( | const std::string & | default_cfg | ) |
Create the initial applications configuration (CiiConfigDocument) from a given string.
| default_cfg | Configuration following YAML syntax. |
| const std::string rad::Config::GetConfigAsString | ( | ) | const |
This method returns the current configuration in a string.
|
inline |
|
inline |
|
inline |
| T rad::Config::GetParam | ( | const std::string & | key | ) | const |
Return the value associated to a configuration parameter.
| key | Identifier of the configuration parameter in OLDB format. |
| bool rad::Config::HasParam | ( | const std::string & | key | ) | const |
Check whether a given parameter is part of the configuration.
| key | Key to convert using a src separator. |
|
virtual |
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. If empty, it reloads the last or default one. |
| void rad::Config::MergeConfig | ( | const elt::configng::CiiConfigDocument & | cfg_doc | ) |
This method merges the given configuration (loaded from file or string) with the main one stored in this class. TODO: This method could/should be provided by CII.
| [in] | config_node | Configuration to merge into the current one. |
|
virtual |
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 rad::Config::Print | ( | ) |
Helper method to print the current application configuration.
| std::string rad::Config::Print | ( | const elt::configng::CiiConfigInstanceNamespace & | instances | ) |
| std::string rad::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.
| std::vector< std::string > rad::Config::SetConfigAsString | ( | const std::string & | config | ) |
This method merges the given configuration with the one currently stored in the Config object. If the configuration is given as a 'key: value'
Note that for the merging to succeed the given configuration must be conistent in terms of data types with one stored.
| config | Configuration to be applied in textual YAML format. |
| void rad::Config::SetParam | ( | const std::string & | key, |
| const T & | value | ||
| ) |
Set the value of a configuration parameter.
| key | Identifier of the configuration parameter in OLDB format. |
| value | The value of a configuration parameter. |