DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ConfigObjectImpl.hpp
Go to the documentation of this file.
1
8#ifndef CONFFWK_CONFIGOBJECTIMPL_H_
9#define CONFFWK_CONFIGOBJECTIMPL_H_
10
11#include <string>
12#include <vector>
13#include <iostream>
14#include <stdint.h>
15
16#include "conffwk/Errors.hpp"
17
18namespace dunedaq {
19namespace conffwk {
20
21class ConfigObject;
22class Configuration;
23class ConfigurationImpl;
24class DalObject;
25class DalObject;
26class DalRegistry;
27
35
51
52 friend class ConfigObject;
53 friend class Configuration;
54 friend class ConfigurationImpl;
55 friend class DalObject;
56 friend class DalObject;
57 friend class DalRegistry;
58
59 public:
60
62 ConfigObjectImpl(ConfigurationImpl * impl, const std::string& id, dunedaq::conffwk::ObjectState state = dunedaq::conffwk::Valid) noexcept;
63
65 virtual ~ConfigObjectImpl() noexcept;
66
67
68 private:
69
70 ConfigObjectImpl() = delete; // do not allow default constructor
71
72
73 public:
74
76 static ConfigObjectImpl * default_impl() noexcept;
77
78
79 public:
80
82 const std::string&
83 UID() const noexcept
84 {
85 std::lock_guard<std::mutex> scoped_lock(m_mutex); // be sure no one renames the object
86 return m_id;
87 }
88
90 const std::string&
91 class_name() const noexcept
92 {
93 return *m_class_name;
94 }
95
97 virtual const std::string contained_in() const = 0;
98
99 public:
100
102 virtual void get(const std::string& attribute, bool& value) = 0;
103
105 virtual void get(const std::string& attribute, uint8_t& value) = 0;
106
108 virtual void get(const std::string& attribute, int8_t& value) = 0;
109
111 virtual void get(const std::string& attribute, uint16_t& value) = 0;
112
114 virtual void get(const std::string& attribute, int16_t& value) = 0;
115
117 virtual void get(const std::string& attribute, uint32_t& value) = 0;
118
120 virtual void get(const std::string& attribute, int32_t& value) = 0;
121
123 virtual void get(const std::string& attribute, uint64_t& value) = 0;
124
126 virtual void get(const std::string& attribute, int64_t& value) = 0;
127
129 virtual void get(const std::string& attribute, float& value) = 0;
130
132 virtual void get(const std::string& attribute, double& value) = 0;
133
135 virtual void get(const std::string& attribute, std::string& value) = 0;
136
138 virtual void get(const std::string& association, ConfigObject& value) = 0;
139
140
141 public:
142
144 virtual void get(const std::string& attribute, std::vector<bool>& value) = 0;
145
147 virtual void get(const std::string& attribute, std::vector<uint8_t>& value) = 0;
148
150 virtual void get(const std::string& attribute, std::vector<int8_t>& value) = 0;
151
153 virtual void get(const std::string& attribute, std::vector<uint16_t>& value) = 0;
154
156 virtual void get(const std::string& attribute, std::vector<int16_t>& value) = 0;
157
159 virtual void get(const std::string& attribute, std::vector<uint32_t>& value) = 0;
160
162 virtual void get(const std::string& attribute, std::vector<int32_t>& value) = 0;
163
165 virtual void get(const std::string& attribute, std::vector<uint64_t>& value) = 0;
166
168 virtual void get(const std::string& attribute, std::vector<int64_t>& value) = 0;
169
171 virtual void get(const std::string& attribute, std::vector<float>& value) = 0;
172
174 virtual void get(const std::string& attribute, std::vector<double>& value) = 0;
175
177 virtual void get(const std::string& attribute, std::vector<std::string>& value) = 0;
178
180 virtual void get(const std::string& association, std::vector<ConfigObject>& value) = 0;
181
182
183 public:
184
186 virtual bool rel(const std::string& name, std::vector<ConfigObject>& value) = 0;
187
189 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;
190
191
192 public:
193
195 virtual void set(const std::string& attribute, bool value) = 0;
196
198 virtual void set(const std::string& attribute, uint8_t value) = 0;
199
201 virtual void set(const std::string& attribute, int8_t value) = 0;
202
204 virtual void set(const std::string& attribute, uint16_t value) = 0;
205
207 virtual void set(const std::string& attribute, int16_t value) = 0;
208
210 virtual void set(const std::string& attribute, uint32_t value) = 0;
211
213 virtual void set(const std::string& attribute, int32_t value) = 0;
214
216 virtual void set(const std::string& attribute, uint64_t value) = 0;
217
219 virtual void set(const std::string& attribute, int64_t value) = 0;
220
222 virtual void set(const std::string& attribute, float value) = 0;
223
225 virtual void set(const std::string& attribute, double value) = 0;
226
228 virtual void set(const std::string& attribute, const std::string& value) = 0;
229
231 virtual void set_enum(const std::string& attribute, const std::string& value) = 0;
232
234 virtual void set_class(const std::string& attribute, const std::string& value) = 0;
235
237 virtual void set_date(const std::string& attribute, const std::string& value) = 0;
238
240 virtual void set_time(const std::string& attribute, const std::string& value) = 0;
241
242
243 public:
244
246 virtual void set(const std::string& attribute, const std::vector<bool>& value) = 0;
247
249 virtual void set(const std::string& attribute, const std::vector<uint8_t>& value) = 0;
250
252 virtual void set(const std::string& attribute, const std::vector<int8_t>& value) = 0;
253
255 virtual void set(const std::string& attribute, const std::vector<uint16_t>& value) = 0;
256
258 virtual void set(const std::string& attribute, const std::vector<int16_t>& value) = 0;
259
261 virtual void set(const std::string& attribute, const std::vector<uint32_t>& value) = 0;
262
264 virtual void set(const std::string& attribute, const std::vector<int32_t>& value) = 0;
265
267 virtual void set(const std::string& attribute, const std::vector<uint64_t>& value) = 0;
268
270 virtual void set(const std::string& attribute, const std::vector<int64_t>& value) = 0;
271
273 virtual void set(const std::string& attribute, const std::vector<float>& value) = 0;
274
276 virtual void set(const std::string& attribute, const std::vector<double>& value) = 0;
277
279 virtual void set(const std::string& attribute, const std::vector<std::string>& value) = 0;
280
282 virtual void set_enum(const std::string& attribute, const std::vector<std::string>& value) = 0;
283
285 virtual void set_class(const std::string& attribute, const std::vector<std::string>& value) = 0;
286
288 virtual void set_date(const std::string& attribute, const std::vector<std::string>& value) = 0;
289
291 virtual void set_time(const std::string& attribute, const std::vector<std::string>& value) = 0;
292
294 virtual void set(const std::string& association, const ConfigObject * value, bool skip_non_null_check) = 0;
295
297 virtual void set(const std::string& association, const std::vector<const ConfigObject*>& value, bool skip_non_null_check) = 0;
298
300 virtual void move(const std::string& at) = 0;
301
303 virtual void rename(const std::string& new_id) = 0;
304
306 virtual void clear() noexcept {;} // by default nothing to do
307
309 virtual void reset() = 0;
310
312 bool
314 {
316 {
317 const_cast<ConfigObjectImpl *>(this)->reset();
318 }
319
321 }
322
323
324 protected:
325
328 std::string m_id;
329 const std::string * m_class_name;
330 mutable std::mutex m_mutex;
333 protected:
334
339 void
341 {
342 if (is_deleted())
343 {
345 }
346 }
347
348
349 private:
350
351 // convert attribute values, if there is a configuration converter
352
353 void convert(bool& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
354 void convert(uint8_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
355 void convert(int8_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
356 void convert(uint16_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
357 void convert(int16_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
358 void convert(uint32_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
359 void convert(int32_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
360 void convert(uint64_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
361 void convert(int64_t& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
362 void convert(float& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
363 void convert(double& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
364 void convert(std::string& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
365 void convert(ConfigObject&, const ConfigObject&, const std::string& ) noexcept {;}
366
367 void convert(std::vector<bool>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
368 void convert(std::vector<uint8_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
369 void convert(std::vector<int8_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
370 void convert(std::vector<uint16_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
371 void convert(std::vector<int16_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
372 void convert(std::vector<uint32_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
373 void convert(std::vector<int32_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
374 void convert(std::vector<uint64_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
375 void convert(std::vector<int64_t>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
376 void convert(std::vector<float>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
377 void convert(std::vector<double>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
378 void convert(std::vector<std::string>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
379 void convert(std::vector<ConfigObject>&, const ConfigObject&, const std::string& ) noexcept {;}
380
381};
382
383} // namespace conffwk
384} // namespace dunedaq
385
386#endif // CONFFWK_CONFIGOBJECTIMPL_H_
#define ERS_HERE
Implements database objects.
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.
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:45
DalRegistry: A registry of DalObjects It provides a single interface to create, cache and manage DalO...
Try to access deleted DAL object.
Definition Errors.hpp:72
Including Qt Headers.