rad  3.0.0
config.hpp
Go to the documentation of this file.
1 
9 #ifndef HELLOMAL_CONFIG_HPP_
10 #define HELLOMAL_CONFIG_HPP_
11 
12 #include <yaml-cpp/yaml.h>
13 
14 #include <string>
15 
16 namespace hellomal {
17 
21 const std::string CONFIG_DEFAULT_PROCNAME = "hellomal";
23 const std::string CONFIG_DEFAULT_FILENAME = "";
24 const std::string CONFIG_DEFAULT_SCXML_FILENAME = "hellomal/sm.xml";
25 const std::string CONFIG_DEFAULT_LOGLEVEL = "INFO";
26 const std::string CONFIG_DEFAULT_LOG_PROPERTIES = "hellomal/log.properties";
27 const std::string CONFIG_DEFAULT_DB_ENDPOINT = "127.0.0.1:6379";
29 const std::string CONFIG_DEFAULT_REQ_ENDPOINT = "zpb.rr://127.0.0.1:12081/";
30 
34 const std::string CONFIG_ENVVAR_DBHOST = "DB_HOST";
35 
40 class Config {
41  public:
49  Config();
50 
54  virtual ~Config();
55 
64  bool ParseOptions(int argc, char* argv[]);
65 
73  void LoadConfig(const std::string& filename = "");
74 
80  const std::string& GetMsgReplierEndpoint() const;
81 
85  const std::string& GetDbEndpoint() const;
86 
90  const timeval GetDbTimeout() const;
91 
95  const std::string& GetSmScxmlFilename() const;
96 
100  const std::string& GetConfigFilename() const;
101 
105  const std::string& GetProcName() const;
106 
110  const std::string& GetLogLevel() const;
111 
115  const std::string& GetLogProperties() const;
116 
117  Config(const Config&) = delete;
118  Config& operator=(const Config&) = delete;
119 
120  private:
121  YAML::Node m_config_node;
122  std::string m_proc_name;
123  std::string m_log_level;
124  std::string m_log_properties;
125  std::string m_config_filename;
126  std::string m_scxml_filename;
127  std::string m_db_host_endpoint;
128  int m_db_timeout_sec;
129  std::string m_req_endpoint;
130 };
131 
132 } // namespace hellomal
133 
134 #endif // HELLOMAL_CONFIG_HPP_
hellomal::CONFIG_DEFAULT_LOG_PROPERTIES
const std::string CONFIG_DEFAULT_LOG_PROPERTIES
Definition: config.hpp:26
hellomal::Config::ParseOptions
bool ParseOptions(int argc, char *argv[])
Definition: config.cpp:63
hellomal::Config::LoadConfig
void LoadConfig(const std::string &filename="")
Definition: config.cpp:144
hellomal::Config::GetProcName
const std::string & GetProcName() const
Definition: config.cpp:232
hellomal::Config::~Config
virtual ~Config()
Definition: config.cpp:59
hellomal::Config::Config
Config(const Config &)=delete
hellomal::CONFIG_DEFAULT_FILENAME
const std::string CONFIG_DEFAULT_FILENAME
no default value to force user to specify config filename since it overwrites the command line option...
Definition: config.hpp:23
hellomal
Definition: actionMgr.cpp:21
hellomal::Config::GetMsgReplierEndpoint
const std::string & GetMsgReplierEndpoint() const
Definition: config.cpp:206
hellomal::Config::GetDbEndpoint
const std::string & GetDbEndpoint() const
Definition: config.cpp:211
hellomal::Config::GetLogLevel
const std::string & GetLogLevel() const
Definition: config.cpp:237
hellomal::Config::GetDbTimeout
const timeval GetDbTimeout() const
Definition: config.cpp:216
hellomal::CONFIG_DEFAULT_DB_ENDPOINT
const std::string CONFIG_DEFAULT_DB_ENDPOINT
Definition: config.hpp:27
hellomal::Config::GetSmScxmlFilename
const std::string & GetSmScxmlFilename() const
Definition: config.cpp:222
hellomal::CONFIG_DEFAULT_DB_TIMEOUT_SEC
const int CONFIG_DEFAULT_DB_TIMEOUT_SEC
Definition: config.hpp:28
hellomal::Config::GetConfigFilename
const std::string & GetConfigFilename() const
Definition: config.cpp:227
hellomal::Config
Definition: config.hpp:40
hellomal::CONFIG_DEFAULT_PROCNAME
const std::string CONFIG_DEFAULT_PROCNAME
Definition: config.hpp:21
hellomal::CONFIG_ENVVAR_DBHOST
const std::string CONFIG_ENVVAR_DBHOST
Definition: config.hpp:34
hellomal::CONFIG_DEFAULT_LOGLEVEL
const std::string CONFIG_DEFAULT_LOGLEVEL
Definition: config.hpp:25
hellomal::Config::GetLogProperties
const std::string & GetLogProperties() const
Definition: config.cpp:242
hellomal::Config::Config
Config()
Definition: config.cpp:26
hellomal::Config::operator=
Config & operator=(const Config &)=delete
Disable copy constructor.
hellomal::CONFIG_DEFAULT_SCXML_FILENAME
const std::string CONFIG_DEFAULT_SCXML_FILENAME
Definition: config.hpp:24
hellomal::CONFIG_DEFAULT_REQ_ENDPOINT
const std::string CONFIG_DEFAULT_REQ_ENDPOINT
Definition: config.hpp:29