DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ConfigObjectImpl.hpp
Go to the documentation of this file.
1//
2// DUNE DAQ modification notice:
3// This file has been modified from the original ATLAS config source for the DUNE DAQ project.
4// Fork baseline commit: 67a24e731 (2022-10-27).
5// Renamed since fork: yes (from config/ConfigObjectImpl.h to include/conffwk/ConfigObjectImpl.hpp).
6//
7
14
15#ifndef CONFFWK_CONFIGOBJECTIMPL_H_
16#define CONFFWK_CONFIGOBJECTIMPL_H_
17
18#include <iostream>
19#include <stdint.h>
20#include <string>
21#include <vector>
22
23#include "conffwk/Errors.hpp"
24
25namespace dunedaq {
26namespace conffwk {
27
28class ConfigObject;
29class Configuration;
31class DalObject;
32class DalObject;
33class DalRegistry;
34
42
56
58{
59
60 friend class ConfigObject;
61 friend class Configuration;
62 friend class ConfigurationImpl;
63 friend class DalObject;
64 friend class DalObject;
65 friend class DalRegistry;
66
67public:
70 const std::string& id,
72
74 virtual ~ConfigObjectImpl() noexcept;
75
76private:
77 ConfigObjectImpl() = delete; // do not allow default constructor
78
79public:
81 static ConfigObjectImpl* default_impl() noexcept;
82
83public:
85 const std::string& UID() const noexcept
86 {
87 std::lock_guard<std::mutex> scoped_lock(m_mutex); // be sure no one renames the object
88 return m_id;
89 }
90
92 const std::string& class_name() const noexcept { return *m_class_name; }
93
95 virtual const std::string contained_in() const = 0;
96
97public:
99 virtual void get(const std::string& attribute, bool& value) = 0;
100
102 virtual void get(const std::string& attribute, uint8_t& value) = 0;
103
105 virtual void get(const std::string& attribute, int8_t& value) = 0;
106
108 virtual void get(const std::string& attribute, uint16_t& value) = 0;
109
111 virtual void get(const std::string& attribute, int16_t& value) = 0;
112
114 virtual void get(const std::string& attribute, uint32_t& value) = 0;
115
117 virtual void get(const std::string& attribute, int32_t& value) = 0;
118
120 virtual void get(const std::string& attribute, uint64_t& value) = 0;
121
123 virtual void get(const std::string& attribute, int64_t& value) = 0;
124
126 virtual void get(const std::string& attribute, float& value) = 0;
127
129 virtual void get(const std::string& attribute, double& value) = 0;
130
132 virtual void get(const std::string& attribute, std::string& value) = 0;
133
135 virtual void get(const std::string& association, ConfigObject& value) = 0;
136
137public:
139 virtual void get(const std::string& attribute, std::vector<bool>& value) = 0;
140
142 virtual void get(const std::string& attribute, std::vector<uint8_t>& value) = 0;
143
145 virtual void get(const std::string& attribute, std::vector<int8_t>& value) = 0;
146
148 virtual void get(const std::string& attribute, std::vector<uint16_t>& value) = 0;
149
151 virtual void get(const std::string& attribute, std::vector<int16_t>& value) = 0;
152
154 virtual void get(const std::string& attribute, std::vector<uint32_t>& value) = 0;
155
157 virtual void get(const std::string& attribute, std::vector<int32_t>& value) = 0;
158
160 virtual void get(const std::string& attribute, std::vector<uint64_t>& value) = 0;
161
163 virtual void get(const std::string& attribute, std::vector<int64_t>& value) = 0;
164
166 virtual void get(const std::string& attribute, std::vector<float>& value) = 0;
167
169 virtual void get(const std::string& attribute, std::vector<double>& value) = 0;
170
172 virtual void get(const std::string& attribute, std::vector<std::string>& value) = 0;
173
175 virtual void get(const std::string& association, std::vector<ConfigObject>& value) = 0;
176
177public:
180 virtual bool rel(const std::string& name, std::vector<ConfigObject>& value) = 0;
181
183 virtual void referenced_by(std::vector<ConfigObject>& value,
184 const std::string& association,
185 bool check_composite_only,
186 unsigned long rlevel,
187 const std::vector<std::string>* rclasses) const = 0;
188
189public:
191 virtual void set(const std::string& attribute, bool value) = 0;
192
194 virtual void set(const std::string& attribute, uint8_t value) = 0;
195
197 virtual void set(const std::string& attribute, int8_t value) = 0;
198
200 virtual void set(const std::string& attribute, uint16_t value) = 0;
201
203 virtual void set(const std::string& attribute, int16_t value) = 0;
204
206 virtual void set(const std::string& attribute, uint32_t value) = 0;
207
209 virtual void set(const std::string& attribute, int32_t value) = 0;
210
212 virtual void set(const std::string& attribute, uint64_t value) = 0;
213
215 virtual void set(const std::string& attribute, int64_t value) = 0;
216
218 virtual void set(const std::string& attribute, float value) = 0;
219
221 virtual void set(const std::string& attribute, double value) = 0;
222
224 virtual void set(const std::string& attribute, const std::string& value) = 0;
225
227 virtual void set_enum(const std::string& attribute, const std::string& value) = 0;
228
230 virtual void set_class(const std::string& attribute, const std::string& value) = 0;
231
233 virtual void set_date(const std::string& attribute, const std::string& value) = 0;
234
236 virtual void set_time(const std::string& attribute, const std::string& value) = 0;
237
238public:
240 virtual void set(const std::string& attribute, const std::vector<bool>& value) = 0;
241
243 virtual void set(const std::string& attribute, const std::vector<uint8_t>& value) = 0;
244
246 virtual void set(const std::string& attribute, const std::vector<int8_t>& value) = 0;
247
249 virtual void set(const std::string& attribute, const std::vector<uint16_t>& value) = 0;
250
252 virtual void set(const std::string& attribute, const std::vector<int16_t>& value) = 0;
253
255 virtual void set(const std::string& attribute, const std::vector<uint32_t>& value) = 0;
256
258 virtual void set(const std::string& attribute, const std::vector<int32_t>& value) = 0;
259
261 virtual void set(const std::string& attribute, const std::vector<uint64_t>& value) = 0;
262
264 virtual void set(const std::string& attribute, const std::vector<int64_t>& value) = 0;
265
267 virtual void set(const std::string& attribute, const std::vector<float>& value) = 0;
268
270 virtual void set(const std::string& attribute, const std::vector<double>& value) = 0;
271
273 virtual void set(const std::string& attribute, const std::vector<std::string>& value) = 0;
274
276 virtual void set_enum(const std::string& attribute, const std::vector<std::string>& value) = 0;
277
279 virtual void set_class(const std::string& attribute, const std::vector<std::string>& value) = 0;
280
282 virtual void set_date(const std::string& attribute, const std::vector<std::string>& value) = 0;
283
285 virtual void set_time(const std::string& attribute, const std::vector<std::string>& value) = 0;
286
288 virtual void set(const std::string& association, const ConfigObject* value, bool skip_non_null_check) = 0;
289
291 virtual void set(const std::string& association,
292 const std::vector<const ConfigObject*>& value,
293 bool skip_non_null_check) = 0;
294
296 virtual void move(const std::string& at) = 0;
297
299 virtual void rename(const std::string& new_id) = 0;
300
302 virtual void clear() noexcept { ; } // by default nothing to do
303
305 virtual void reset() = 0;
306
308 bool is_deleted() const
309 {
311 const_cast<ConfigObjectImpl*>(this)->reset();
312 }
313
315 }
316
317protected:
320 std::string m_id;
321 const std::string* m_class_name;
322 mutable std::mutex m_mutex;
323
324protected:
329 void throw_if_deleted() const
330 {
331 if (is_deleted()) {
332 throw dunedaq::conffwk::DeletedObject(ERS_HERE, m_class_name->c_str(), m_id.c_str());
333 }
334 }
335
336private:
337 // convert attribute values, if there is a configuration converter
338
339 void convert(bool& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
340 void convert(uint8_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
341 void convert(int8_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
342 void convert(uint16_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
343 void convert(int16_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
344 void convert(uint32_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
345 void convert(int32_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
346 void convert(uint64_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
347 void convert(int64_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
348 void convert(float& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
349 void convert(double& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
350 void convert(std::string& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
351 void convert(ConfigObject&, const ConfigObject&, const std::string&) noexcept { ; }
352
353 void convert(std::vector<bool>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
354 void convert(std::vector<uint8_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
355 void convert(std::vector<int8_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
356 void convert(std::vector<uint16_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
357 void convert(std::vector<int16_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
358 void convert(std::vector<uint32_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
359 void convert(std::vector<int32_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
360 void convert(std::vector<uint64_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
361 void convert(std::vector<int64_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
362 void convert(std::vector<float>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
363 void convert(std::vector<double>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
364 void convert(std::vector<std::string>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
365 void convert(std::vector<ConfigObject>&, const ConfigObject&, const std::string&) noexcept { ; }
366};
367
368} // namespace conffwk
369} // namespace dunedaq
370
371#endif // CONFFWK_CONFIGOBJECTIMPL_H_
#define ERS_HERE
virtual void set(const std::string &attribute, const std::vector< int64_t > &value)=0
Virtual method to read vector-of-signed-64-bits-integers attribute value.
virtual void get(const std::string &attribute, int64_t &value)=0
Virtual method to read signed 64 bits integer attribute value.
virtual void get(const std::string &attribute, std::vector< uint64_t > &value)=0
Virtual method to read vector-of-unsigned-64-bits-integers attribute value.
virtual void set_date(const std::string &attribute, const std::vector< std::string > &value)=0
Virtual method to read vector-of-dates attribute value.
virtual void get(const std::string &association, std::vector< ConfigObject > &value)=0
Virtual method to read vector-of-conffwk-objects relationship value.
virtual void set_class(const std::string &attribute, const std::vector< std::string > &value)=0
Virtual method to read vector-of-enumerations attribute value.
virtual void get(const std::string &attribute, std::vector< int8_t > &value)=0
Virtual method to read vector-of-signed-chars attribute value.
virtual void set(const std::string &attribute, const std::vector< uint32_t > &value)=0
Virtual method to read vector-of-unsigned-longs attribute value.
virtual void set(const std::string &attribute, const std::string &value)=0
Virtual method to set string attribute value.
virtual void get(const std::string &attribute, int32_t &value)=0
Virtual method to read signed long attribute value.
virtual void get(const std::string &attribute, uint64_t &value)=0
Virtual method to read unsigned 64 bits integer attribute value.
virtual void set(const std::string &association, const ConfigObject *value, bool skip_non_null_check)=0
Virtual method to read conffwk-object relationship value.
void convert(bool &value, const ConfigObject &obj, const std::string &attr_name) noexcept
const std::string & UID() const noexcept
Method to get database object's unique ID.
virtual void rename(const std::string &new_id)=0
Virtual method to change object ID.
virtual void set(const std::string &attribute, const std::vector< int32_t > &value)=0
Virtual method to read vector-of-signed-longs attribute value.
virtual void set(const std::string &attribute, const std::vector< uint16_t > &value)=0
Virtual method to read vector-of-unsigned-shorts attribute value.
virtual void set(const std::string &attribute, double value)=0
Virtual method to set double attribute value.
virtual void get(const std::string &attribute, std::vector< uint16_t > &value)=0
Virtual method to read vector-of-unsigned-shorts attribute value.
virtual void set(const std::string &attribute, int16_t value)=0
Virtual method to set signed short attribute value.
virtual void clear() noexcept
Virtual method to clean resources used by the implementation object.
const std::string & class_name() const noexcept
Virtual method to get object's class name.
virtual void get(const std::string &attribute, float &value)=0
Virtual method to read float attribute value.
virtual const std::string contained_in() const =0
Virtual method to get object's database file name.
virtual void set(const std::string &attribute, bool value)=0
Virtual method to set boolean attribute value.
virtual void set(const std::string &attribute, float value)=0
Virtual method to set float attribute value.
virtual void referenced_by(std::vector< ConfigObject > &value, const std::string &association, bool check_composite_only, unsigned long rlevel, const std::vector< std::string > *rclasses) const =0
Virtual method to read vector-of-conffwk-object referencing this object.
virtual void set(const std::string &attribute, int64_t value)=0
Virtual method to set signed 64 bits integer attribute value.
static ConfigObjectImpl * default_impl() noexcept
Returns default implementation.
virtual void get(const std::string &attribute, std::vector< bool > &value)=0
Virtual method to read vector-of-booleans attribute value.
virtual void set(const std::string &attribute, const std::vector< uint8_t > &value)=0
Virtual method to read vector-of-unsigned-chars attribute value.
virtual void set(const std::string &attribute, uint32_t value)=0
Virtual method to set unsigned long attribute value.
virtual bool rel(const std::string &name, std::vector< ConfigObject > &value)=0
virtual void get(const std::string &attribute, uint32_t &value)=0
Virtual method to read unsigned long attribute value.
virtual void get(const std::string &attribute, std::vector< float > &value)=0
Virtual method to read vector-of-floats attribute value.
virtual void get(const std::string &attribute, std::vector< int32_t > &value)=0
Virtual method to read vector-of-signed-longs attribute value.
virtual void get(const std::string &attribute, std::vector< double > &value)=0
Virtual method to read vector-of-doubles attribute value.
virtual void set(const std::string &attribute, uint8_t value)=0
Virtual method to set unsigned char attribute value.
virtual void get(const std::string &attribute, std::vector< std::string > &value)=0
Virtual method to read vector-of-strings attribute value.
virtual void get(const std::string &attribute, std::vector< int64_t > &value)=0
Virtual method to read vector-of-signed-64-bits-integers attribute value.
virtual void set(const std::string &attribute, const std::vector< float > &value)=0
Virtual method to read vector-of-floats attribute value.
virtual void set(const std::string &attribute, const std::vector< uint64_t > &value)=0
Virtual method to read vector-of-unsigned-64-bits-integers attribute value.
virtual void reset()=0
Virtual method to reset the implementation object from unknown state.
virtual void set(const std::string &attribute, uint16_t value)=0
Virtual method to set unsigned short attribute value.
virtual void get(const std::string &attribute, std::vector< int16_t > &value)=0
Virtual method to read vector-of-signed-shorts attribute value.
virtual void get(const std::string &attribute, std::string &value)=0
Virtual method to read string attribute value.
void convert(ConfigObject &, const ConfigObject &, const std::string &) noexcept
void convert(std::vector< ConfigObject > &, const ConfigObject &, const std::string &) noexcept
dunedaq::conffwk::ObjectState m_state
virtual void get(const std::string &attribute, double &value)=0
Virtual method to read double attribute value.
bool is_deleted() const
Check object and return true if the object has been deleted.
virtual void get(const std::string &association, ConfigObject &value)=0
Virtual method to read relationship single-value.
virtual void set_time(const std::string &attribute, const std::string &value)=0
Virtual method to set time attribute value.
virtual void set(const std::string &attribute, uint64_t value)=0
Virtual method to set unsigned 64 bits integer attribute value.
virtual void move(const std::string &at)=0
Virtual method to move object to a file.
virtual void set(const std::string &attribute, const std::vector< bool > &value)=0
Virtual method to read vector-of-booleans attribute value.
virtual void set_enum(const std::string &attribute, const std::vector< std::string > &value)=0
Virtual method to read vector-of-enumerations attribute value.
virtual void set(const std::string &attribute, const std::vector< std::string > &value)=0
Virtual method to read vector-of-strings attribute value.
virtual void set(const std::string &association, const std::vector< const ConfigObject * > &value, bool skip_non_null_check)=0
Virtual method to read vector-of-conffwk-objects relationship value.
virtual void set(const std::string &attribute, const std::vector< double > &value)=0
Virtual method to read vector-of-doubles attribute value.
ConfigObjectImpl(ConfigurationImpl *impl, const std::string &id, dunedaq::conffwk::ObjectState state=dunedaq::conffwk::Valid) noexcept
The constructor stores configuration implementation pointer.
virtual void get(const std::string &attribute, uint8_t &value)=0
Virtual method to read unsigned char attribute value.
virtual void get(const std::string &attribute, int16_t &value)=0
Virtual method to read signed short attribute value.
virtual void set_enum(const std::string &attribute, const std::string &value)=0
Virtual method to set enumeration attribute value.
virtual void set(const std::string &attribute, int8_t value)=0
Virtual method to set signed char attribute value.
virtual void get(const std::string &attribute, int8_t &value)=0
Virtual method to read signed char attribute value.
virtual void get(const std::string &attribute, uint16_t &value)=0
Virtual method to read unsigned short attribute value.
virtual void get(const std::string &attribute, bool &value)=0
Virtual method to read boolean attribute value.
virtual void set_class(const std::string &attribute, const std::string &value)=0
Virtual method to set enumeration attribute value.
virtual void set_date(const std::string &attribute, const std::string &value)=0
Virtual method to set date attribute value.
virtual void get(const std::string &attribute, std::vector< uint8_t > &value)=0
Virtual method to read vector-of-unsigned-chars attribute value.
virtual void set(const std::string &attribute, const std::vector< int16_t > &value)=0
Virtual method to read vector-of-signed-shorts attribute value.
virtual void set(const std::string &attribute, int32_t value)=0
Virtual method to set signed long attribute value.
virtual void get(const std::string &attribute, std::vector< uint32_t > &value)=0
Virtual method to read vector-of-unsigned-longs attribute value.
virtual void set(const std::string &attribute, const std::vector< int8_t > &value)=0
Virtual method to read vector-of-signed-chars attribute value.
virtual void set_time(const std::string &attribute, const std::vector< std::string > &value)=0
Virtual method to read vector-of-times attribute value.
Represents database objects.
Provides pure virtual interface used by the Configuration class.
Defines base class for cache of template objects.
The base class for any generated DAL object.
Definition DalObject.hpp:51
DalRegistry: A registry of DalObjects It provides a single interface to create, cache and manage DalO...
The DUNE-DAQ namespace.
msgpack::object obj