DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DataStore.hpp
Go to the documentation of this file.
1
10
11// 09-Sep-2020, KAB: the initial version of this class was based on the
12// Queue interface from the appfwk repo.
13
14#ifndef DFMODULES_INCLUDE_DFMODULES_DATASTORE_HPP_
15#define DFMODULES_INCLUDE_DFMODULES_DATASTORE_HPP_
16
18#include "cetlib/BasicPluginFactory.h"
19#include "cetlib/compiler_macros.h"
23#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
26
27#include "nlohmann/json.hpp"
28
29#include <chrono>
30#include <cstddef>
31#include <memory>
32#include <string>
33#include <vector>
34
35#ifndef EXTERN_C_FUNC_DECLARE_START
36// NOLINTNEXTLINE(build/define_used)
37#define EXTERN_C_FUNC_DECLARE_START \
38 extern "C" \
39 {
40#endif
45// NOLINTNEXTLINE(build/define_used)
46#define DEFINE_DUNE_DATA_STORE(klass) \
47 EXTERN_C_FUNC_DECLARE_START \
48 std::shared_ptr<dunedaq::dfmodules::DataStore> make(const std::string& name, \
49 std::shared_ptr<dunedaq::appfwk::ConfigurationManager> mcfg, \
50 const std::string& writer_name) \
51 { \
52 return std::shared_ptr<dunedaq::dfmodules::DataStore>(new klass(name, mcfg, writer_name)); \
53 } \
54 }
55
56namespace dunedaq {
57
62ERS_DECLARE_ISSUE(dfmodules,
63 DataStoreCreationFailed,
64 "Failed to create DataStore " << plugin_name << " with name " << name,
65 ((std::string)plugin_name)((std::string)name)
66)
68
74ERS_DECLARE_ISSUE(dfmodules,
75 RetryableDataStoreProblem,
76 "Module " << mod_name << ": A problem was encountered when " << description,
77 ((std::string)mod_name)((std::string)description))
79
85ERS_DECLARE_ISSUE(dfmodules,
86 IgnorableDataStoreProblem,
87 "Module " << mod_name << ": A problem was encountered when " << description,
88 ((std::string)mod_name)((std::string)description))
90
91namespace dfmodules {
92
99{
100public:
105 explicit DataStore(const std::string& name)
106 : utilities::NamedObject(name)
108 {
109 }
110
116 virtual void write(const daqdataformats::TriggerRecord& tr) = 0;
117
124 virtual void write(const daqdataformats::TimeSlice& ts) = 0;
125
132 virtual void prepare_for_run(daqdataformats::run_number_t run_number, bool run_is_for_test_purposes) = 0;
133
140 virtual void finish_with_run(daqdataformats::run_number_t run_number) = 0;
141
142private:
143 DataStore(const DataStore&) = delete;
144 DataStore& operator=(const DataStore&) = delete;
145 DataStore(DataStore&&) = delete;
147};
148
156inline std::shared_ptr<DataStore>
157make_data_store(const std::string& type,
158 const std::string& name,
159 std::shared_ptr<dunedaq::appfwk::ConfigurationManager> mcfg,
160 const std::string& writer_identifier)
161{
162 static cet::BasicPluginFactory bpf("duneDataStore", "make"); // NOLINT
163
164 std::shared_ptr<DataStore> ds;
165 try {
166 ds = bpf.makePlugin<std::shared_ptr<DataStore>>(type, name, mcfg, writer_identifier);
167 } catch (const cet::exception& cexpt) {
168 throw DataStoreCreationFailed(ERS_HERE, type, name, cexpt);
169 }
170
171 return ds;
172}
173
174} // namespace dfmodules
175} // namespace dunedaq
176
177#endif // DFMODULES_INCLUDE_DFMODULES_DATASTORE_HPP_
#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.
MonitorableObject(const MonitorableObject &)=delete
Implements the Named interface.
NamedObject(const std::string &name)
NamedObject Constructor.
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message_, attributes)
Definition macro.hpp:71
An ERS Issue for DataStore creation failure.
Definition DataStore.hpp:91
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.
The DUNE-DAQ namespace.