DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DataStore.hpp
Go to the documentation of this file.
1
12// 09-Sep-2020, KAB: the initial version of this class was based on the
13// Queue interface from the appfwk repo.
14
15#ifndef DFMODULES_INCLUDE_DFMODULES_DATASTORE_HPP_
16#define DFMODULES_INCLUDE_DFMODULES_DATASTORE_HPP_
17
20#include "cetlib/BasicPluginFactory.h"
21#include "cetlib/compiler_macros.h"
25#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
27
28#include "nlohmann/json.hpp"
29
30#include <chrono>
31#include <cstddef>
32#include <memory>
33#include <string>
34#include <vector>
35
36#ifndef EXTERN_C_FUNC_DECLARE_START
37// NOLINTNEXTLINE(build/define_used)
38#define EXTERN_C_FUNC_DECLARE_START \
39 extern "C" \
40 {
41#endif
46// NOLINTNEXTLINE(build/define_used)
47#define DEFINE_DUNE_DATA_STORE(klass) \
48 EXTERN_C_FUNC_DECLARE_START \
49 std::shared_ptr<dunedaq::dfmodules::DataStore> make(const std::string& name, \
50 std::shared_ptr<dunedaq::appfwk::ConfigurationManager> mcfg, \
51 const std::string& writer_name ) \
52 { \
53 return std::shared_ptr<dunedaq::dfmodules::DataStore>(new klass(name, mcfg, writer_name)); \
54 } \
55 }
56
57namespace dunedaq {
58
63ERS_DECLARE_ISSUE(dfmodules,
64 DataStoreCreationFailed,
65 "Failed to create DataStore " << plugin_name << " with name " << name,
66 ((std::string)plugin_name)((std::string)name)
67)
69
75ERS_DECLARE_ISSUE(dfmodules,
76 RetryableDataStoreProblem,
77 "Module " << mod_name << ": A problem was encountered when " << description,
78 ((std::string)mod_name)((std::string)description))
80
86ERS_DECLARE_ISSUE(dfmodules,
87 IgnorableDataStoreProblem,
88 "Module " << mod_name << ": A problem was encountered when " << description,
89 ((std::string)mod_name)((std::string)description))
91
97ERS_DECLARE_ISSUE(dfmodules,
98 GeneralDataStoreProblem,
99 "Module " << mod_name << ": A problem was encountered when " << description,
100 ((std::string)mod_name)((std::string)description))
102
103namespace dfmodules {
104
109{
110public:
115 explicit DataStore(const std::string& name)
116 : utilities::NamedObject(name), MonitorableObject()
117 {
118 }
119
124 virtual void write(const daqdataformats::TriggerRecord& tr) = 0;
125
130 virtual void write(const daqdataformats::TimeSlice& ts) = 0;
131
139 bool run_is_for_test_purposes) = 0;
140
147 virtual void finish_with_run(daqdataformats::run_number_t run_number) = 0;
148
149private:
150 DataStore(const DataStore&) = delete;
151 DataStore& operator=(const DataStore&) = delete;
152 DataStore(DataStore&&) = delete;
154};
155
163inline std::shared_ptr<DataStore>
164make_data_store(const std::string& type,
165 const std::string& name,
166 std::shared_ptr<dunedaq::appfwk::ConfigurationManager> mcfg,
167 const std::string& writer_identifier)
168{
169 static cet::BasicPluginFactory bpf("duneDataStore", "make"); // NOLINT
170
171 std::shared_ptr<DataStore> ds;
172 try {
173 ds = bpf.makePlugin<std::shared_ptr<DataStore>>(type, name, mcfg, writer_identifier);
174 } catch (const cet::exception& cexpt) {
175 throw DataStoreCreationFailed(ERS_HERE, type, name, cexpt);
176 }
177
178 return ds;
179}
180
181} // namespace dfmodules
182} // namespace dunedaq
183
184#endif // DFMODULES_INCLUDE_DFMODULES_DATASTORE_HPP_
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define ERS_HERE
C++ Representation of a DUNE TimeSlice, consisting of a TimeSliceHeader object and a vector of pointe...
Definition TimeSlice.hpp:27
C++ Representation of a DUNE TriggerRecord, consisting of a TriggerRecordHeader object and a vector o...
DataStore & operator=(const DataStore &)=delete
virtual void write(const daqdataformats::TriggerRecord &tr)=0
Writes the TriggerRecord into the DataStore.
virtual void finish_with_run(daqdataformats::run_number_t run_number)=0
Informs the DataStore that writes or reads of data blocks associated with the specified run number ha...
DataStore & operator=(DataStore &&)=delete
DataStore(DataStore &&)=delete
DataStore(const DataStore &)=delete
virtual void write(const daqdataformats::TimeSlice &ts)=0
Writes the TimeSlice into the DataStore.
virtual void prepare_for_run(daqdataformats::run_number_t run_number, bool run_is_for_test_purposes)=0
Informs the DataStore that writes or reads of data blocks associated with the specified run number wi...
DataStore(const std::string &name)
DataStore Constructor.
Implements the Named interface.
uint32_t run_number_t
Type used to represent run number.
Definition Types.hpp:20
std::shared_ptr< DataStore > make_data_store(const std::string &type, const std::string &name, std::shared_ptr< dunedaq::appfwk::ConfigurationManager > mcfg, const std::string &writer_identifier)
Load a DataSrore plugin and return a unique_ptr to the contained DAQModule class.
Including Qt Headers.
Unknown serialization type