rad 8.2.0
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1
9#ifndef {{cookiecutter.module_name|upper}}_CONFIG_HPP_
10#define {{cookiecutter.module_name|upper}}_CONFIG_HPP_
11
12#include <yaml-cpp/yaml.h>
13
14#include <string>
15
16namespace {{cookiecutter.module_name}} {
17
21const std::string CONFIG_DEFAULT_PROCNAME = "{{cookiecutter.application_name}}";
23const std::string CONFIG_DEFAULT_FILENAME = ""; // "{{cookiecutter.module_name}}/config.yaml";
24const std::string CONFIG_DEFAULT_SCXML_FILENAME = "{{cookiecutter.module_name}}/sm.xml";
25const std::string CONFIG_DEFAULT_LOG_LEVEL = "INFO";
26const std::string CONFIG_DEFAULT_LOG_PROPERTIES = "{{cookiecutter.module_name}}/log.properties";
27const std::string CONFIG_DEFAULT_DB_ENDPOINT = "127.0.0.1:6379";
28const int CONFIG_DEFAULT_DB_TIMEOUT = 2; // sec
29const std::string CONFIG_DEFAULT_REQ_ENDPOINT = "tcp://*:5577";
30const std::string CONFIG_DEFAULT_SUB_ENDPOINT = "tcp://127.0.0.1::5560";
31
35const std::string CONFIG_ENVVAR_DBHOST = "DB_HOST";
36
37
46class Config
47{
48public:
49 Config();
50 virtual ~Config();
51
52 bool ParseOptions(int argc, char *argv[]);
53
54 void LoadConfig(const std::string& filename = "");
55
56 const std::string& GetMsgReplierEndpoint() const;
57 const std::string& GetMsgSubEndpoint() const;
58
59 const std::string& GetDbEndpoint() const;
60 const timeval GetDbTimeout() const;
61
62 const std::string& GetSmScxmlFilename() const;
63
64 const std::string& GetConfigFilename() const;
65 const std::string& GetProcName() const;
66 const std::string& GetLogLevel() const;
67 const std::string& GetLogProperties() const;
68
69 Config(const Config&) = delete;
70 Config& operator= (const Config&) = delete;
71
72private:
73 YAML::Node m_config_node;
74
75 std::string m_proc_name;
76 std::string m_log_level;
77 std::string m_log_properties;
78 std::string m_config_filename;
79 std::string m_scxml_filename;
80 std::string m_db_host_endpoint;
81 int m_db_timeout_sec;
82 std::string m_req_endpoint;
83 std::string m_sub_endpoint;
84};
85
86} // namespace {{cookiecutter.module_name}}
87
88#endif // {{cookiecutter.module_name|upper}}_CONFIG_HPP_
89
const std::string CONFIG_DEFAULT_LOG_PROPERTIES
Definition config.hpp:33
const std::string CONFIG_DEFAULT_REQ_ENDPOINT
Definition config.hpp:34
const std::string CONFIG_DEFAULT_LOG_LEVEL
Definition config.hpp:32
const std::string CONFIG_DEFAULT_PROCNAME
Definition config.hpp:27
const std::string CONFIG_DEFAULT_FILENAME
Definition config.hpp:29
const std::string CONFIG_DEFAULT_SCXML_FILENAME
Definition config.hpp:30
const std::string CONFIG_ENVVAR_DBHOST
Definition config.hpp:35
const std::string CONFIG_DEFAULT_DB_ENDPOINT
Definition config.hpp:28
const int CONFIG_DEFAULT_DB_TIMEOUT
Definition config.hpp:28
const std::string CONFIG_DEFAULT_SUB_ENDPOINT
Definition config.hpp:30
#define cookiecutter