DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ConfigObject.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/ConfigObject.h to include/conffwk/ConfigObject.hpp).
6//
7
14
15#ifndef CONFFWK_CONFIGOBJECT_H_
16#define CONFFWK_CONFIGOBJECT_H_
17
18#include <string>
19#include <vector>
20#include <iostream>
21
22#include <mutex>
23
25#include "conffwk/Errors.hpp"
26
27namespace dunedaq {
28namespace conffwk {
29
30class Configuration;
31
52
54
55 friend class Configuration;
56 friend class ConfigurationImpl;
57 friend class DalObject;
58 friend class DalRegistry;
59
60 public:
61
70
71 ConfigObject() noexcept;
72
73
80
81 ConfigObject(const ConfigObject& other) noexcept;
82
83
87
88 ConfigObject(ConfigObjectImpl *impl) noexcept;
89
90
94
95 ~ConfigObject() noexcept;
96
97
104
105 ConfigObject& operator=(const ConfigObject& other) noexcept;
106
107
111
112 ConfigObject& operator=(ConfigObjectImpl *impl) noexcept;
113
114
118
119 bool operator==(const ConfigObject& other) const noexcept;
120
121 ConfigObject* get_obj_pybind(const std::string& attrname);
122
123 template <typename T>
124 T get_value_pybind(const std::string& attrname) {
125 T attrval;
126 this->get(attrname, attrval);
127 return attrval;
128 }
129
130 template <typename T>
131 std::vector<T> get_list_pybind(const std::string& attrname) {
132 std::vector<T> attrvals;
133 this->get(attrname, attrvals);
134 return attrvals;
135 }
136
137 template <typename T>
138 void set_list_pybind(const std::string& attrname, std::vector<T> l) {
139 this->set_by_ref(attrname, l);
140 }
141
142
143
144// private:
145// void set_string_list_generic(ConfigObject& co, const std::string& attrname, std::vector<std::string> data,
146// void (ConfigObject::*f)(const std::string&, const std::vector<std::string>&)) {
147// (co.*f)(attrname, data);
148// }
149
150// public:
151
152// void set_string_list
153// (ConfigObject& co, const std::string& attrname, boost::python::list& l) {
154// set_string_list_generic(co, attrname, l,
155// &ConfigObject::set_by_ref<const std::vector<std::string> >);
156// }
157
158// void set_enum_list
159// (ConfigObject& co, const std::string& attrname, boost::python::list& l) {
160// set_string_list_generic(co, attrname, l, &ConfigObject::set_enum);
161// }
162
163// void set_class_list
164// (ConfigObject& co, const std::string& attrname, boost::python::list& l) {
165// set_string_list_generic(co, attrname, l, &ConfigObject::set_class);
166// }
167
168// void set_date_list
169// (ConfigObject& co, const std::string& attrname, boost::python::list& l) {
170// set_string_list_generic(co, attrname, l, &ConfigObject::set_date);
171// }
172
173// void set_time_list
174// (ConfigObject& co, const std::string& attrname, boost::python::list& l) {
175// set_string_list_generic(co, attrname, l, &ConfigObject::set_time);
176// }
177
186
187 bool
188 is_null() const noexcept
189 {
190 return (m_impl == nullptr);
191 }
192
193
197
198 bool
200 {
201 return (m_impl->is_deleted());
202 }
203
204
205 private:
206
207 void action_on_object_update(Configuration * db, const std::string& name);
208
209
210
211 public:
212
213
224
225 const std::string& UID() const noexcept { return m_impl->m_id; }
226
227
237
238 const std::string& class_name() const noexcept { return *m_impl->m_class_name; }
239
240
247
248 const std::string full_name() const noexcept { return UID() + '@' + class_name(); }
249
250
255
256 const std::string contained_in() const
257 {
258 return m_impl->contained_in();
259 }
260
261
284
285 template<class T> void get(const std::string& name, T& value) {
286 m_impl->get(name, value);
287 m_impl->convert(value, *this, name);
288 }
289
290
302
303 bool
304 rel(const std::string& name, std::vector<ConfigObject>& value)
305 {
306 if (m_impl->rel(name, value))
307 {
308 m_impl->convert(value, *this, name);
309 return true;
310 }
311
312 return false;
313 }
314
315
333
334 void referenced_by(std::vector<ConfigObject>& value,
335 const std::string& relationship_name = "*",
336 bool check_composite_only = true,
337 unsigned long rlevel = 0,
338 const std::vector<std::string> * rclasses = nullptr ) const {
339 m_impl->referenced_by(value, relationship_name, check_composite_only, rlevel, rclasses);
340 }
341
344
345
355
356 void set_obj(const std::string& name, const ConfigObject * o, bool skip_non_null_check = false) {
357 m_impl->set(name, o, skip_non_null_check);
359 }
360
361
371
372 void set_objs(const std::string& name, const std::vector<const ConfigObject*> & o, bool skip_non_null_check = false) {
373 m_impl->set(name, o, skip_non_null_check);
375 }
376
377
397
398 template<class T> void set_by_val(const std::string& name, T value) {
399 m_impl->set(name, value);
401 }
402
403
418
419 template<class T> void set_by_ref(const std::string& name, T& value) {
420 m_impl->set(name, value);
422 }
423
424
435
436 void set_enum(const std::string& name, const std::string& value) {
437 m_impl->set_enum(name, value);
439 }
440
441
452
453 void set_class(const std::string& name, const std::string& value) {
454 m_impl->set_class(name, value);
456 }
457
458
469
470 void set_date(const std::string& name, const std::string& value) {
471 m_impl->set_date(name, value);
473 }
474
475
486
487 void set_time(const std::string& name, const std::string& value) {
488 m_impl->set_time(name, value);
490 }
491
492
503
504 void set_enum(const std::string& name, const std::vector<std::string>& value) {
505 m_impl->set_enum(name, value);
507 }
508
509
520
521 void set_class(const std::string& name, const std::vector<std::string>& value) {
522 m_impl->set_class(name, value);
524 }
525
526
537
538 void set_date(const std::string& name, const std::vector<std::string>& value) {
539 m_impl->set_date(name, value);
541 }
542
543
554
555 void set_time(const std::string& name, const std::vector<std::string>& value) {
556 m_impl->set_time(name, value);
558 }
559
560
570
571 void move(const std::string& at) {
572 m_impl->move(at);
573 }
574
575
585
586 void
587 rename(const std::string& new_id);
588
589
593
594 void print_ptr(std::ostream& s) const noexcept;
595
596
600
601 void print_ref(
602 std::ostream& s,
603 Configuration & conf,
604 const std::string& prefix = "",
605 bool show_contained_in = false
606 ) const noexcept;
607
608
614
615 const ConfigObjectImpl * implementation() const noexcept {return m_impl;}
616
617
618 private:
619
620 void
621 _clear() noexcept
622 {
623 if (m_impl)
624 {
625 m_impl->clear();
626 }
627 }
628
629
630 private:
631
633
634};
635
636
638
639std::ostream& operator<<(std::ostream&, const ConfigObject *);
640
641
643
644std::ostream& operator<<(std::ostream&, const ConfigObject &);
645
646} // namespace conffwk
647} // namespace dunedaq
648
649#endif // CONFFWK_CONFIGOBJECT_H_
Implements database objects.
Represents database objects.
void set_time(const std::string &name, const std::string &value)
Set attribute time value.
void set_by_val(const std::string &name, T value)
Set attribute value.
ConfigObject * get_obj_pybind(const std::string &attrname)
void set_time(const std::string &name, const std::vector< std::string > &value)
Set attribute vector-of-times value.
T get_value_pybind(const std::string &attrname)
ConfigObject() noexcept
Default constructor.
void set_class(const std::string &name, const std::vector< std::string > &value)
Set attribute vector-of-class value.
void set_date(const std::string &name, const std::string &value)
Set attribute date value.
void print_ptr(std::ostream &s) const noexcept
Print object's pointer in format 'obj-id@class-name'.
void set_objs(const std::string &name, const std::vector< const ConfigObject * > &o, bool skip_non_null_check=false)
Set relationship multi-value.
void move(const std::string &at)
Move object to a different database.
const std::string & UID() const noexcept
Return object identity.
void set_enum(const std::string &name, const std::vector< std::string > &value)
Set attribute vector-of-enumerations value.
Configuration * get_configuration() const
Get pointer to configuration object.
void set_class(const std::string &name, const std::string &value)
Set attribute class value.
void set_by_ref(const std::string &name, T &value)
Set attribute value.
bool is_deleted() const
Check if object was deleted.
void action_on_object_update(Configuration *db, const std::string &name)
void set_list_pybind(const std::string &attrname, std::vector< T > l)
void set_date(const std::string &name, const std::vector< std::string > &value)
Set attribute vector-of-dates value.
void print_ref(std::ostream &s, Configuration &conf, const std::string &prefix="", bool show_contained_in=false) const noexcept
Print details of object's attributes and relationships.
void get(const std::string &name, T &value)
Get value of object's attribute or relationship.
void set_enum(const std::string &name, const std::string &value)
Set attribute enumeration value.
void referenced_by(std::vector< ConfigObject > &value, const std::string &relationship_name="*", bool check_composite_only=true, unsigned long rlevel=0, const std::vector< std::string > *rclasses=nullptr) const
Get objects which have references to given object.
const std::string full_name() const noexcept
Return full object name.
void set_obj(const std::string &name, const ConfigObject *o, bool skip_non_null_check=false)
Set relationship single-value.
bool is_null() const noexcept
Check if object's implementation points to null.
const ConfigObjectImpl * implementation() const noexcept
Returns pointer on implementation.
void rename(const std::string &new_id)
Rename object.
std::vector< T > get_list_pybind(const std::string &attrname)
const std::string & class_name() const noexcept
Return object's class name.
bool rel(const std::string &name, std::vector< ConfigObject > &value)
Get value of object's relationship.
const std::string contained_in() const
Return the name of the database file this object belongs to.
Defines base class for cache of template objects.
std::ostream & operator<<(std::ostream &, const ConfigurationChange &)
Including Qt Headers.
Definition module.cpp:16