ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
dbInterface.cpp
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 source file.
8 */
9
10#include "dbInterface.hpp"
11#include "config.hpp"
12#include "logger.hpp"
13
14#include <rad/assert.hpp>
15#include <rad/exceptions.hpp>
16#include <rad/oldbInterface.hpp> // KEY_MON_STATE
17
18namespace server {
19
20DbInterface::DbInterface(const std::string& prefix, rad::OldbAsyncWriter& writer)
21 : m_prefix(prefix), m_runtime_db(writer) {
22 RAD_TRACE(GetLogger());
23 if (prefix.empty()) {
24 throw std::invalid_argument("OLDB prefix is invalid (empty)");
25 }
26 if (prefix.back() != '/') {
27 m_prefix.push_back('/');
28 }
29}
30
32 RAD_TRACE(GetLogger());
33}
34
35void DbInterface::SetControlState(const std::string& value) {
36 RAD_TRACE(GetLogger());
37 m_runtime_db.Set(m_prefix + rad::KEY_MON_STATE, value);
38}
39
41 RAD_TRACE(GetLogger());
42 cfg.GetMgr().Visit([&](daq::config::Manager::CiiValue const& param) {
43 m_runtime_db.Set(m_prefix + param.metadata.canonical_name, param.value);
44 });
45}
46
47void DbInterface::Set(const std::string& key, const std::string& value) {
48 RAD_TRACE(GetLogger());
49 m_runtime_db.Set(m_prefix + key, value);
50}
51
52} // namespace server
void Visit(Func &&func)
Visit each registered parameter.
Definition: manager.hpp:230
rad::cii::OldbType value
Definition: manager.hpp:210
Metadata const & metadata
Definition: manager.hpp:212
CII representation of real value.
Definition: manager.hpp:209
This class provide access to the command line options and the configuration parameters stored in the ...
Definition: config.hpp:61
daq::config::Manager & GetMgr()
Definition: config.hpp:157
DbInterface(const std::string &prefix, rad::OldbAsyncWriter &runtime_db)
Constructor.
Definition: dbInterface.cpp:20
void Set(const std::string &key, const std::string &value)
Definition: dbInterface.cpp:47
void SetConfig(Config &cfg)
Set the application configuration information in the DB.
Definition: dbInterface.cpp:40
void SetControlState(const std::string &value)
Definition: dbInterface.cpp:35
virtual ~DbInterface()
Destructor.
Definition: dbInterface.cpp:31
DbInterface class header file.
Default logger name.
std::string canonical_name
Definition: manager.hpp:74
log4cplus::Logger & GetLogger()
Definition: logger.cpp:14
Config class header file.