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 <string>
19#include <vector>
20#include <iostream>
21#include <stdint.h>
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 friend class ConfigObject;
60 friend class Configuration;
61 friend class ConfigurationImpl;
62 friend class DalObject;
63 friend class DalObject;
64 friend class DalRegistry;
65
66 public:
67
69 ConfigObjectImpl(ConfigurationImpl * impl, const std::string& id, dunedaq::conffwk::ObjectState state = dunedaq::conffwk::Valid) noexcept;
70
72 virtual ~ConfigObjectImpl() noexcept;
73
74
75 private:
76
77 ConfigObjectImpl() = delete; // do not allow default constructor
78
79
80 public:
81
83 static ConfigObjectImpl * default_impl() noexcept;
84
85
86 public:
87
89 const std::string&
90 UID() const noexcept
91 {
92 std::lock_guard<std::mutex> scoped_lock(m_mutex); // be sure no one renames the object
93 return m_id;
94 }
95
97 const std::string&
98 class_name() const noexcept
99 {
100 return *m_class_name;
101 }
102
104 virtual const std::string contained_in() const = 0;
105
106 public:
107
109 virtual void get(const std::string& attribute, bool& value) = 0;
110
112 virtual void get(const std::string& attribute, uint8_t& value) = 0;
113
115 virtual void get(const std::string& attribute, int8_t& value) = 0;
116
118 virtual void get(const std::string& attribute, uint16_t& value) = 0;
119
121 virtual void get(const std::string& attribute, int16_t& value) = 0;
122
124 virtual void get(const std::string& attribute, uint32_t& value) = 0;
125
127 virtual void get(const std::string& attribute, int32_t& value) = 0;
128
130 virtual void get(const std::string& attribute, uint64_t& value) = 0;
131
133 virtual void get(const std::string& attribute, int64_t& value) = 0;
134
136 virtual void get(const std::string& attribute, float& value) = 0;
137
139 virtual void get(const std::string& attribute, double& value) = 0;
140
142 virtual void get(const std::string& attribute, std::string& value) = 0;
143
145 virtual void get(const std::string& association, ConfigObject& value) = 0;
146
147
148 public:
149
151 virtual void get(const std::string& attribute, std::vector<bool>& value) = 0;
152
154 virtual void get(const std::string& attribute, std::vector<uint8_t>& value) = 0;
155
157 virtual void get(const std::string& attribute, std::vector<int8_t>& value) = 0;
158
160 virtual void get(const std::string& attribute, std::vector<uint16_t>& value) = 0;
161
163 virtual void get(const std::string& attribute, std::vector<int16_t>& value) = 0;
164
166 virtual void get(const std::string& attribute, std::vector<uint32_t>& value) = 0;
167
169 virtual void get(const std::string& attribute, std::vector<int32_t>& value) = 0;
170
172 virtual void get(const std::string& attribute, std::vector<uint64_t>& value) = 0;
173
175 virtual void get(const std::string& attribute, std::vector<int64_t>& value) = 0;
176
178 virtual void get(const std::string& attribute, std::vector<float>& value) = 0;
179
181 virtual void get(const std::string& attribute, std::vector<double>& value) = 0;
182
184 virtual void get(const std::string& attribute, std::vector<std::string>& value) = 0;
185
187 virtual void get(const std::string& association, std::vector<ConfigObject>& value) = 0;
188
189
190 public:
191
193 virtual bool rel(const std::string& name, std::vector<ConfigObject>& value) = 0;
194
196 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;
197
198
199 public:
200
202 virtual void set(const std::string& attribute, bool value) = 0;
203
205 virtual void set(const std::string& attribute, uint8_t value) = 0;
206
208 virtual void set(const std::string& attribute, int8_t value) = 0;
209
211 virtual void set(const std::string& attribute, uint16_t value) = 0;
212
214 virtual void set(const std::string& attribute, int16_t value) = 0;
215
217 virtual void set(const std::string& attribute, uint32_t value) = 0;
218
220 virtual void set(const std::string& attribute, int32_t value) = 0;
221
223 virtual void set(const std::string& attribute, uint64_t value) = 0;
224
226 virtual void set(const std::string& attribute, int64_t value) = 0;
227
229 virtual void set(const std::string& attribute, float value) = 0;
230
232 virtual void set(const std::string& attribute, double value) = 0;
233
235 virtual void set(const std::string& attribute, const std::string& value) = 0;
236
238 virtual void set_enum(const std::string& attribute, const std::string& value) = 0;
239
241 virtual void set_class(const std::string& attribute, const std::string& value) = 0;
242
244 virtual void set_date(const std::string& attribute, const std::string& value) = 0;
245
247 virtual void set_time(const std::string& attribute, const std::string& value) = 0;
248
249
250 public:
251
253 virtual void set(const std::string& attribute, const std::vector<bool>& value) = 0;
254
256 virtual void set(const std::string& attribute, const std::vector<uint8_t>& value) = 0;
257
259 virtual void set(const std::string& attribute, const std::vector<int8_t>& value) = 0;
260
262 virtual void set(const std::string& attribute, const std::vector<uint16_t>& value) = 0;
263
265 virtual void set(const std::string& attribute, const std::vector<int16_t>& value) = 0;
266
268 virtual void set(const std::string& attribute, const std::vector<uint32_t>& value) = 0;
269
271 virtual void set(const std::string& attribute, const std::vector<int32_t>& value) = 0;
272
274 virtual void set(const std::string& attribute, const std::vector<uint64_t>& value) = 0;
275
277 virtual void set(const std::string& attribute, const std::vector<int64_t>& value) = 0;
278
280 virtual void set(const std::string& attribute, const std::vector<float>& value) = 0;
281
283 virtual void set(const std::string& attribute, const std::vector<double>& value) = 0;
284
286 virtual void set(const std::string& attribute, const std::vector<std::string>& value) = 0;
287
289 virtual void set_enum(const std::string& attribute, const std::vector<std::string>& value) = 0;
290
292 virtual void set_class(const std::string& attribute, const std::vector<std::string>& value) = 0;
293
295 virtual void set_date(const std::string& attribute, const std::vector<std::string>& value) = 0;
296
298 virtual void set_time(const std::string& attribute, const std::vector<std::string>& value) = 0;
299
301 virtual void set(const std::string& association, const ConfigObject * value, bool skip_non_null_check) = 0;
302
304 virtual void set(const std::string& association, const std::vector<const ConfigObject*>& value, bool skip_non_null_check) = 0;
305
307 virtual void move(const std::string& at) = 0;
308
310 virtual void rename(const std::string& new_id) = 0;
311
313 virtual void clear() noexcept {;} // by default nothing to do
314
316 virtual void reset() = 0;
317
319 bool
321 {
323 {
324 const_cast<ConfigObjectImpl *>(this)->reset();
325 }
326
328 }
329
330
331 protected:
332
335 std::string m_id;
336 const std::string * m_class_name;
337 mutable std::mutex m_mutex;
338
339
340 protected:
341
346 void
348 {
349 if (is_deleted())
350 {
351 throw dunedaq::conffwk::DeletedObject(ERS_HERE, m_class_name->c_str(), m_id.c_str());
352 }
353 }
354
355
356 private:
357
358 // convert attribute values, if there is a configuration converter
359
360 void convert(bool& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
361 void convert(uint8_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
362 void convert(int8_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
363 void convert(uint16_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
364 void convert(int16_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
365 void convert(uint32_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
366 void convert(int32_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
367 void convert(uint64_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
368 void convert(int64_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
369 void convert(float& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
370 void convert(double& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
371 void convert(std::string& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
372 void convert(ConfigObject&, const ConfigObject&, const std::string& ) noexcept {;}
373
374 void convert(std::vector<bool>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
375 void convert(std::vector<uint8_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
376 void convert(std::vector<int8_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
377 void convert(std::vector<uint16_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
378 void convert(std::vector<int16_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
379 void convert(std::vector<uint32_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
380 void convert(std::vector<int32_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
381 void convert(std::vector<uint64_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
382 void convert(std::vector<int64_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
383 void convert(std::vector<float>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
384 void convert(std::vector<double>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
385 void convert(std::vector<std::string>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
386 void convert(std::vector<ConfigObject>&, const ConfigObject&, const std::string& ) noexcept {;}
387
388};
389
390} // namespace conffwk
391} // namespace dunedaq
392
393#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 method to read any relationship value without throwing an exception if there is no such relat...
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 ~ConfigObjectImpl() noexcept
The virtual destructor.
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:52
DalRegistry: A registry of DalObjects It provides a single interface to create, cache and manage DalO...
Including Qt Headers.
Definition module.cpp:16
msgpack::object obj