ifw-fcf  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dbInterface.hpp
Go to the documentation of this file.
1 
8 #ifndef FCF_DEVMGR_COMMON_DB_INTERFACE_HPP_
9 #define FCF_DEVMGR_COMMON_DB_INTERFACE_HPP_
10 
11 // System headers
12 #include <string>
13 #include <mutex>
14 
15 // Local headers
16 #include <rad/dbAdapter.hpp>
17 
18 namespace fcf {
19  namespace devmgr {
20  namespace common {
21 
22  const std::string KEY_CONTROL_STATE = "state";
23  const std::string KEY_CONTROL_SUBSTATE = "substate";
24  const std::string KEY_CONTROL_STATUS = "status";
25 
26  const std::string KEY_CONTROL_STATE_STR = "state_str";
27  const std::string KEY_CONTROL_SUBSTATE_STR = "substate_str";
28 
29  const std::string KEY_CONFIG_REQ_ENDPOINT = "req_endpoint";
30  const std::string KEY_CONFIG_PUB_ENDPOINT = "pub_endpoint";
31  const std::string KEY_CONFIG_SUB_ENDPOINT = "sub_endpoint";
32  const std::string KEY_CONFIG_EXT_PUB_ENDPOINT = "ext_pub_endpoint";
33  const std::string KEY_CONFIG_EXT_SUB_ENDPOINT = "ext_sub_endpoint";
34  const std::string KEY_CONFIG_DB_ENDPOINT = "db_endpoint";
35  const std::string KEY_CONFIG_DB_TIMEOUT = "db_timeout";
36  const std::string KEY_CONFIG_SM_SCXML = "scxml";
37  const std::string KEY_CONFIG_FILENAME = "filename";
38  const std::string KEY_CONFIG_LOG_LEVEL = "loglevel";
39 
40  const std::string KEY_CONFIG_SERVER_ID = "server_id";
41  const std::string KEY_CONFIG_SERVER = "server";
42  const std::string KEY_CONFIG_DEVICES = "devices";
43  const std::string KEY_CONFIG_DEVFILE = "cfgfile";
44  const std::string KEY_CONFIG_CMDTOUT = "cmdtout";
45  const std::string KEY_CONFIG_TYPE = "type";
46  const std::string KEY_CONFIG_DICTIONARIES = "dictionaries";
47  const std::string KEY_CONFIG_PREFIX = "fits_prefix";
48 
49 
53  class DbInterface {
54  public:
61  DbInterface(const std::string& prefix, rad::DbAdapter& runtime_db);
62 
66  virtual ~DbInterface();
67 
71  std::string GetControlState();
72 
76  std::string GetControlSubstate();
77 
81  std::string GetControlStatus();
82 
87  std::string Get(const std::string& key);
88 
92  void SetControlState(const std::string& value);
93 
97  void SetControlSubstate(const std::string& value);
98 
102  void SetControlStatus(const std::string& value);
103 
110  void SetControl(const std::string& state,
111  const std::string& substate);
112 
119  void SetControl(const short state,
120  const short substate);
121 
132  void SetConfig(const std::string& req_endpoint,
133  const std::string& db_endpoint,
134  const timeval& db_timeout,
135  const std::string& scxml_filename,
136  const std::string& config_filename,
137  const std::string& log_level);
138 
143  void Set(const std::string& key, const std::string& value);
144 
149  void MultiSet(std::vector<std::string>& kvs);
150 
151  DbInterface(const DbInterface&) = delete;
152  DbInterface& operator=(const DbInterface&) = delete;
153 
154  private:
155  std::string m_prefix;
156  rad::DbAdapter& m_runtime_db;
157  std::timed_mutex m_mutex;
158  };
159 
160  }
161  } // namespace common
162 } // namespace devmgr
163 
164 #endif // FCF_DEVMGR_COMMON_DB_INTERFACE_HPP_
const std::string KEY_CONTROL_STATE_STR
Definition: dbInterface.hpp:26
std::string GetControlSubstate()
Definition: dbInterface.cpp:43
void MultiSet(std::vector< std::string > &kvs)
Definition: dbInterface.cpp:147
void SetConfig(const std::string &req_endpoint, const std::string &db_endpoint, const timeval &db_timeout, const std::string &scxml_filename, const std::string &config_filename, const std::string &log_level)
Definition: dbInterface.cpp:117
const std::string KEY_CONFIG_SERVER
Definition: dbInterface.hpp:41
const std::string KEY_CONFIG_DB_TIMEOUT
Definition: dbInterface.hpp:35
const std::string KEY_CONFIG_DB_ENDPOINT
Definition: dbInterface.hpp:34
std::string GetControlState()
Definition: dbInterface.cpp:38
Definition: dbInterface.hpp:53
const std::string KEY_CONFIG_DEVFILE
Definition: dbInterface.hpp:43
const std::string KEY_CONFIG_SUB_ENDPOINT
Definition: dbInterface.hpp:31
const std::string KEY_CONFIG_LOG_LEVEL
Definition: dbInterface.hpp:38
const std::string KEY_CONFIG_REQ_ENDPOINT
Definition: dbInterface.hpp:29
const std::string KEY_CONTROL_STATE
Definition: dbInterface.hpp:22
DbInterface & operator=(const DbInterface &)=delete
Disable assignment operator.
const std::string KEY_CONFIG_DEVICES
Definition: dbInterface.hpp:42
const std::string KEY_CONFIG_EXT_PUB_ENDPOINT
Definition: dbInterface.hpp:32
DbInterface(const std::string &prefix, rad::DbAdapter &runtime_db)
Definition: dbInterface.cpp:24
virtual ~DbInterface()
Definition: dbInterface.cpp:34
void SetControlState(const std::string &value)
Definition: dbInterface.cpp:58
const std::string KEY_CONTROL_SUBSTATE
Definition: dbInterface.hpp:23
const std::string KEY_CONFIG_SERVER_ID
Definition: dbInterface.hpp:40
const std::string KEY_CONTROL_SUBSTATE_STR
Definition: dbInterface.hpp:27
const std::string KEY_CONFIG_PREFIX
Definition: dbInterface.hpp:47
const std::string KEY_CONFIG_FILENAME
Definition: dbInterface.hpp:37
std::string GetControlStatus()
Definition: dbInterface.cpp:48
const std::string KEY_CONFIG_CMDTOUT
Definition: dbInterface.hpp:44
const std::string KEY_CONTROL_STATUS
Definition: dbInterface.hpp:24
const std::string KEY_CONFIG_SM_SCXML
Definition: dbInterface.hpp:36
void SetControlSubstate(const std::string &value)
Definition: dbInterface.cpp:68
void SetControlStatus(const std::string &value)
Definition: dbInterface.cpp:78
void SetControl(const std::string &state, const std::string &substate)
Definition: dbInterface.cpp:87
const std::string KEY_CONFIG_TYPE
Definition: dbInterface.hpp:45
std::string Get(const std::string &key)
Definition: dbInterface.cpp:53
const std::string KEY_CONFIG_DICTIONARIES
Definition: dbInterface.hpp:46
const std::string KEY_CONFIG_PUB_ENDPOINT
Definition: dbInterface.hpp:30
void Set(const std::string &key, const std::string &value)
Definition: dbInterface.cpp:173
const std::string KEY_CONFIG_EXT_SUB_ENDPOINT
Definition: dbInterface.hpp:33