DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
VariableBase.cpp
Go to the documentation of this file.
4#include "conffwk/Errors.hpp"
6
7#include "logging/Logging.hpp"
8
9namespace dunedaq {
10 namespace confmodel {
11 const std::string& VariableBase::s_class_name(dunedaq::conffwk::DalFactory::instance().get_known_class_name_ref("VariableBase"));
12
13 // the constructor
14
20
21
22 void VariableBase::print(unsigned int indent, bool print_header, std::ostream& s) const
23 {
24 check_init();
25
26 try {
27 const std::string str(indent+2, ' ');
28
29 if (print_header)
30 p_hdr(s, indent, s_class_name, "dunedaq::confmodel");
31
32
33 // print direct attributes
34
36 }
37 catch (dunedaq::conffwk::Exception & ex) {
39 }
40 }
41
42
43 void VariableBase::init(bool /* init_children */)
44 {
45 p_was_read = true;
47 TLOG_DEBUG(5) << "read object " << this << " (class " << s_class_name << ')';
48
49 try {
51 }
52 catch (dunedaq::conffwk::Exception & ex) {
53 throw_init_ex(ex);
54 }
55 }
56
58 {
59 }
60
61 std::vector<const dunedaq::conffwk::DalObject *> VariableBase::get(const std::string& name, bool upcast_unregistered) const
62 {
63 std::vector<const dunedaq::conffwk::DalObject *> vec;
64
65 if (!get(name, vec, upcast_unregistered, true))
66 throw_get_ex(name, s_class_name, this);
67
68 return vec;
69 }
70
71 bool VariableBase::get(const std::string& name, std::vector<const dunedaq::conffwk::DalObject *>& vec, bool upcast_unregistered, bool first_call) const
72 {
73 if (first_call)
74 {
75 std::lock_guard scoped_lock(m_mutex);
76
77 check();
78 check_init();
79
80 if (get_rel_objects(name, upcast_unregistered, vec))
81 return true;
82 }
83
84 if (first_call)
85 return get_algo_objects(name, vec);
86
87 return false;
88 }
89
90 }
91}
void get(const std::string &name, T &value)
Get value of object's attribute or relationship.
The base class for any generated DAL object.
Definition DalObject.hpp:45
void p_hdr(std::ostream &s, unsigned int indent, const std::string &cl, const char *nm=nullptr) const
print object headers
Definition DalObject.cpp:65
void throw_init_ex(dunedaq::conffwk::Exception &ex)
throw object initialisation exception (i.e.
Definition DalObject.cpp:74
void increment_read() noexcept
static void p_error(std::ostream &s, dunedaq::conffwk::Exception &ex)
print error text
Definition DalObject.cpp:59
bool get_rel_objects(const std::string &name, bool upcast_unregistered, std::vector< const DalObject * > &objs) const
Read relationship values as DAL objects using DAL factory.
Definition DalObject.cpp:8
static void throw_get_ex(const std::string &what, const std::string &class_name, const DalObject *obj)
throw exception in generated get method (i.e.
Definition DalObject.cpp:82
std::mutex m_mutex
Used to protect changes of DAL object.
bool p_was_read
is true, if the object was read
bool get_algo_objects(const std::string &name, std::vector< const DalObject * > &objs) const
Run algorithm and return result as DAL objects using DAL factory.
Definition DalObject.cpp:25
ConfigObject p_obj
Config object used by given template object.
void check_init() const
Check and initialize object if necessary.
DalRegistry: A registry of DalObjects It provides a single interface to create, cache and manage DalO...
virtual void print(unsigned int offset, bool print_header, std::ostream &s) const
Print details of the VariableBase object.
static const std::string s_description
VariableBase(conffwk::DalRegistry &db, const conffwk::ConfigObject &obj) noexcept
static const std::string & s_class_name
virtual std::vector< const dunedaq::conffwk::DalObject * > get(const std::string &name, bool upcast_unregistered=true) const
Get values of relationships and results of some algorithms as a vector of dunedaq::conffwk::DalObject...
virtual void init(bool init_children)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
void p_sv_attr(std::ostream &s, const std::string &str, const std::string &name, const T &val) noexcept
print single-value attribute
Including Qt Headers.