ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
dataContext.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 DataContext class source file.
8  */
9 
10 #include "dataContext.hpp"
11 #include "logger.hpp"
12 
13 #include <rad/assert.hpp>
14 #include <rad/exceptions.hpp>
15 
16 
17 namespace server {
18 
19 DataContext::DataContext(Config& config, rad::OldbAsyncWriter& writer)
20 : m_config(config),
21  m_db_interface(m_config.GetDbPrefix(), writer) {
22  RAD_TRACE(GetLogger());
23  UpdateDb();
24 }
25 
27  RAD_TRACE(GetLogger());
28 }
29 
31  RAD_TRACE(GetLogger());
32 
33  m_config.LoadConfig(m_config.GetConfigFilename());
34  UpdateDb();
35 }
36 
38  RAD_TRACE(GetLogger());
39 
40  try {
41  m_db_interface.SetConfig(m_config);
42  } catch (rad::Exception const& e) {
43  /*
44  * Log error but do not terminate, DB could be temporarily unavailable.
45  */
46  LOG4CPLUS_ERROR(GetLogger(), e.what());
47  }
48 }
49 
51  RAD_TRACE(GetLogger());
52  return m_db_interface;
53 }
54 
55 } // namespace server
56 
This class provide access to the command line options and the configuration parameters stored in the ...
Definition: config.hpp:60
const std::string & GetConfigFilename() const
Definition: config.cpp:317
void LoadConfig(const std::string &filename="")
This method load from a configuration file the application configuration overriding the initializatio...
Definition: config.cpp:166
virtual ~DataContext()
Destructor.
Definition: dataContext.cpp:26
void UpdateDb()
Try to connect to the DB and update the application configuration.
Definition: dataContext.cpp:37
DataContext(Config &config, rad::OldbAsyncWriter &writer)
This constructor uses the application configuration to initialize the adapter object to the in-memory...
Definition: dataContext.cpp:19
void ReloadConfig()
Reload the configuration from file and reconnect to the in-memory DB.
Definition: dataContext.cpp:30
DbInterface & GetDbInterface()
Definition: dataContext.cpp:50
This class is the write-only interface to the CII OLDB.
Definition: dbInterface.hpp:46
void SetConfig(Config &cfg)
Set the application configuration information in the DB.
Definition: dbInterface.cpp:40
DataContext class header file.
Default logger name.
log4cplus::Logger & GetLogger()
Definition: logger.cpp:14