ifw-ocf  2.0.0-dev
 All Classes Namespaces Files Functions Variables Groups
config.hpp
Go to the documentation of this file.
1 
9 #ifndef SERVER_CONFIG_HPP_
10 #define SERVER_CONFIG_HPP_
11 
12 #include <yaml-cpp/yaml.h>
13 
14 #include <string>
15 
16 namespace server {
17 
21 const std::string CONFIG_DEFAULT_PROCNAME = "ocmServer";
23 const std::string CONFIG_DEFAULT_FILENAME = "ocs/ocmServerCfg.yaml";
24 const std::string CONFIG_DEFAULT_SCXML_FILENAME = "ocmServerSm.xml";
25 const std::string CONFIG_DEFAULT_LOGLEVEL = "INFO";
26 const std::string CONFIG_DEFAULT_DB_ENDPOINT = "127.0.0.1:6379";
28 const std::string CONFIG_DEFAULT_REQ_ENDPOINT = "tcp://*:5577";
29 
33 const std::string CONFIG_ENVVAR_DBHOST = "DB_HOST";
34 
39 class Config {
40  public:
48  Config();
49 
53  virtual ~Config();
54 
63  bool ParseOptions(int argc, char* argv[]);
64 
72  void LoadConfig(const std::string& filename = "");
73 
79  const std::string& GetMsgReplierEndpoint() const;
80 
84  const std::string& GetDbEndpoint() const;
85 
89  const timeval GetDbTimeout() const;
90 
94  const std::string& GetSmScxmlFilename() const;
95 
99  const std::string& GetConfigFilename() const;
100 
104  const std::string& GetProcName() const;
105 
109  const std::string& GetLogLevel() const;
110 
111  Config(const Config&) = delete;
112  Config& operator=(const Config&) = delete;
113 
114  private:
115  YAML::Node m_config_node;
116  std::string m_proc_name;
117  std::string m_log_level;
118  std::string m_config_filename;
119  std::string m_scxml_filename;
120  std::string m_db_host_endpoint;
121  int m_db_timeout_sec;
122  std::string m_req_endpoint;
123 };
124 
125 } // namespace server
126 
127 #endif // SERVER_CONFIG_HPP_
const std::string & GetConfigFilename() const
Definition: config.cpp:218
const std::string CONFIG_DEFAULT_DB_ENDPOINT
Definition: config.hpp:26
const std::string & GetProcName() const
Definition: config.cpp:223
Definition: config.hpp:39
bool ParseOptions(int argc, char *argv[])
Definition: config.cpp:61
Config & operator=(const Config &)=delete
Disable copy constructor.
const std::string & GetLogLevel() const
Definition: config.cpp:228
const std::string & GetDbEndpoint() const
Definition: config.cpp:202
const std::string & GetSmScxmlFilename() const
Definition: config.cpp:213
Config()
Definition: config.cpp:26
const std::string CONFIG_DEFAULT_LOGLEVEL
Definition: config.hpp:25
const std::string CONFIG_DEFAULT_REQ_ENDPOINT
Definition: config.hpp:28
const std::string CONFIG_DEFAULT_SCXML_FILENAME
Definition: config.hpp:24
const timeval GetDbTimeout() const
Definition: config.cpp:207
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
void LoadConfig(const std::string &filename="")
Definition: config.cpp:141
const int CONFIG_DEFAULT_DB_TIMEOUT_SEC
Definition: config.hpp:27
virtual ~Config()
Definition: config.cpp:57
const std::string & GetMsgReplierEndpoint() const
Definition: config.cpp:197
const std::string CONFIG_DEFAULT_PROCNAME
Definition: config.hpp:21
const std::string CONFIG_ENVVAR_DBHOST
Definition: config.hpp:33