ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
dbInterface.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup server
4  * @copyright ESO - European Southern Observatory
5  * @author
6  *
7  * @brief DbInterface class header file.
8  */
9 #ifndef SERVER_DB_INTERFACE_HPP_
10 #define SERVER_DB_INTERFACE_HPP_
11 
12 #include <rad/dbAdapter.hpp>
13 
14 #include <string>
15 
16 namespace server {
17 
18 const std::string KEY_CONTROL_STATE = "ctr.state";
19 
20 const std::string KEY_CONFIG_REQ_ENDPOINT = "cfg.req.endpoint";
21 const std::string KEY_CONFIG_PUB_ENDPOINT = "cfg.pub.endpoint";
22 const std::string KEY_CONFIG_DB_ENDPOINT = "cfg.db.endpoint";
23 const std::string KEY_CONFIG_DB_PREFIX = "cfg.db.prefix";
24 const std::string KEY_CONFIG_DB_TIMEOUT_SEC = "cfg.db.timeout_sec";
25 const std::string KEY_CONFIG_SM_SCXML = "cfg.sm.scxml";
26 const std::string KEY_CONFIG_FILENAME = "cfg.filename";
27 const std::string KEY_CONFIG_LOG_LEVEL = "cfg.log.level";
28 const std::string KEY_CONFIG_LOG_PROPERTIES = "cfg.log.properties";
29 const std::string KEY_CONFIG_INSTRUMENT_ID = "cfg.instrument_id";
30 const std::string KEY_CONFIG_DATAROOT = "cfg.dataroot";
31 const std::string KEY_CONFIG_WORKSPACE = "cfg.workspace";
32 
33 const std::string KEY_CONFIG_STALE_DAQ_ACQUIRING = "cfg.daq.stale.acquiring_hours";
34 const std::string KEY_CONFIG_STALE_DAQ_MERGING = "cfg.daq.stale.merging_hours";
35 
36 const std::string KEY_CONFIG_DPM_REQ_ENDPOINT = "cfg.dpm.req.endpoint";
37 const std::string KEY_CONFIG_DPM_PUB_ENDPOINT = "cfg.dpm.pub.endpoint";
38 const std::string KEY_CONFIG_DPM_TIMEOUT_SEC = "cfg.dpm.timeout_sec";
39 
40 class Config;
41 
42 
43 /**
44  * This class is the interface to the in-memory DB.
45  */
46 class DbInterface {
47  public:
48  /**
49  * Constructor.
50  *
51  * @param[in] prefix String used as prefix when building the keys.
52  * @param[in] runtime_db Reference to the in-memory DB adapter.
53  */
54  DbInterface(const std::string& prefix, rad::DbAdapter& runtime_db);
55 
56  /**
57  * Destructor
58  */
59  virtual ~DbInterface();
60 
61  /**
62  * @return The current state of the application stored in the DB.
63  */
64  std::string GetControlState();
65 
66  /**
67  * @param[in] key Key in the DB.
68  * @return The value stored in the DB associated to the given key.
69  */
70  std::string Get(const std::string& key);
71 
72  /**
73  * @param[in] value State to be stored in the DB.
74  */
75  void SetControlState(const std::string& value);
76 
77  /**
78  * Set the application configuration information in the DB.
79  *
80  * @param[in] reqEndpoint Request msg endpoint.
81  * @param[in] dbIpAddr DB IP address.
82  * @param[in] dbPort DB port.
83  * @param[in] dbTimeout DB timeout.
84  */
85  void SetConfig(Config& cfg);
86 
87  /**
88  * @param[in] key Key to be written in the DB.
89  * @param[in] value Value, associated to the given key, to be written in the DB.
90  */
91  void Set(const std::string& key, const std::string& value);
92 
93  DbInterface(const DbInterface&) = delete; //! Disable copy constructor
94  DbInterface& operator=(const DbInterface&) = delete; //! Disable assignment operator
95 
96  private:
97  std::string m_prefix;
98  rad::DbAdapter& m_runtime_db;
99 };
100 
101 } // namespace server
102 
103 #endif // SERVER_DB_INTERFACE_HPP_
server::KEY_CONFIG_DPM_TIMEOUT_SEC
const std::string KEY_CONFIG_DPM_TIMEOUT_SEC
Definition: dbInterface.hpp:38
server::KEY_CONFIG_REQ_ENDPOINT
const std::string KEY_CONFIG_REQ_ENDPOINT
Definition: dbInterface.hpp:20
server::KEY_CONFIG_DATAROOT
const std::string KEY_CONFIG_DATAROOT
Definition: dbInterface.hpp:30
server::DbInterface::Set
void Set(const std::string &key, const std::string &value)
Definition: dbInterface.cpp:89
server::DbInterface::~DbInterface
virtual ~DbInterface()
Destructor.
Definition: dbInterface.cpp:30
server::DbInterface::Get
std::string Get(const std::string &key)
Definition: dbInterface.cpp:39
server::KEY_CONFIG_FILENAME
const std::string KEY_CONFIG_FILENAME
Definition: dbInterface.hpp:26
server::DbInterface
This class is the interface to the in-memory DB.
Definition: dbInterface.hpp:46
server::KEY_CONFIG_PUB_ENDPOINT
const std::string KEY_CONFIG_PUB_ENDPOINT
Definition: dbInterface.hpp:21
server::KEY_CONFIG_DB_PREFIX
const std::string KEY_CONFIG_DB_PREFIX
Definition: dbInterface.hpp:23
server::DbInterface::SetConfig
void SetConfig(Config &cfg)
Set the application configuration information in the DB.
Definition: dbInterface.cpp:49
server::KEY_CONFIG_INSTRUMENT_ID
const std::string KEY_CONFIG_INSTRUMENT_ID
Definition: dbInterface.hpp:29
server::KEY_CONFIG_DPM_REQ_ENDPOINT
const std::string KEY_CONFIG_DPM_REQ_ENDPOINT
Definition: dbInterface.hpp:36
server::KEY_CONFIG_WORKSPACE
const std::string KEY_CONFIG_WORKSPACE
Definition: dbInterface.hpp:31
server::KEY_CONFIG_DB_ENDPOINT
const std::string KEY_CONFIG_DB_ENDPOINT
Definition: dbInterface.hpp:22
server::DbInterface::DbInterface
DbInterface(const DbInterface &)=delete
server::KEY_CONTROL_STATE
const std::string KEY_CONTROL_STATE
Definition: dbInterface.hpp:18
server::KEY_CONFIG_LOG_LEVEL
const std::string KEY_CONFIG_LOG_LEVEL
Definition: dbInterface.hpp:27
server::DbInterface::SetControlState
void SetControlState(const std::string &value)
Definition: dbInterface.cpp:44
server::KEY_CONFIG_DB_TIMEOUT_SEC
const std::string KEY_CONFIG_DB_TIMEOUT_SEC
Definition: dbInterface.hpp:24
server::KEY_CONFIG_STALE_DAQ_ACQUIRING
const std::string KEY_CONFIG_STALE_DAQ_ACQUIRING
Definition: dbInterface.hpp:33
server
Definition: actionMgr.cpp:21
server::DbInterface::DbInterface
DbInterface(const std::string &prefix, rad::DbAdapter &runtime_db)
Constructor.
Definition: dbInterface.cpp:20
server::KEY_CONFIG_DPM_PUB_ENDPOINT
const std::string KEY_CONFIG_DPM_PUB_ENDPOINT
Definition: dbInterface.hpp:37
server::DbInterface::GetControlState
std::string GetControlState()
Definition: dbInterface.cpp:34
server::DbInterface::operator=
DbInterface & operator=(const DbInterface &)=delete
Disable copy constructor.
server::KEY_CONFIG_LOG_PROPERTIES
const std::string KEY_CONFIG_LOG_PROPERTIES
Definition: dbInterface.hpp:28
server::Config
This class provide access to the command line options and the configuration parameters stored in the ...
Definition: config.hpp:46
server::KEY_CONFIG_SM_SCXML
const std::string KEY_CONFIG_SM_SCXML
Definition: dbInterface.hpp:25
server::KEY_CONFIG_STALE_DAQ_MERGING
const std::string KEY_CONFIG_STALE_DAQ_MERGING
Definition: dbInterface.hpp:34