DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DalObject.cpp
Go to the documentation of this file.
2
3namespace dunedaq {
4namespace conffwk {
5
6
7bool
8DalObject::get_rel_objects(const std::string &name, bool upcast_unregistered, std::vector<const DalObject*> &objs) const
9{
10 std::vector<conffwk::ConfigObject> c_objs;
11
12 if (const_cast<conffwk::ConfigObject*>(&p_obj)->rel(name, c_objs))
13 {
14 // Fixme: what about the lock?
15 // std::lock_guard<std::mutex> scoped_lock(p_registry.m_tmpl_mutex);
16 p_registry.get(c_objs, upcast_unregistered).swap(objs);
17 return true;
18 }
19
20 return false;
21}
22
23
24bool
25DalObject::get_algo_objects(const std::string& /* name */, std::vector<const DalObject*>& /* objs */) const
26{
27 // FIXME: Remove
28// const std::string &suitable_dal_class = DalFactory::instance().class4algo(p_registry, class_name(), name);
29
30// TLOG_DEBUG(2) << "suitable class for algorithm " << name << " on object " << this << " is " << suitable_dal_class;
31
32// if (!suitable_dal_class.empty())
33// if (const DalObject *obj = p_registry.make_dal_object(const_cast<conffwk::ConfigObject&>(p_obj), UID(), suitable_dal_class))
34// {
35// obj->get(name, false).swap(objs);
36// return true;
37// }
38
39 return false;
40}
41
42
43
44 // DalObject helper
45
46void
47DalObject::p_null(std::ostream &s)
48{
49 s << "(null)";
50}
51
52void
53DalObject::p_rm(std::ostream &s)
54{
55 s << "(deleted object)";
56}
57
58void
59DalObject::p_error(std::ostream &s, dunedaq::conffwk::Exception &ex)
60{
61 s << "ERROR in generated DAL print method:\n\twas caused by: " << ex << std::endl;
62}
63
64void
65DalObject::p_hdr(std::ostream &s, unsigned int indent, const std::string &cl, const char *nm) const
66{
67 const std::string str(indent, ' ');
68 s << str;
69 if (nm)
70 s << nm << ' ';
71 s << cl << " object:\n" << str << " id: \'" << UID() << "\', class name: \'" << DalObject::class_name() << "\'\n";
72}
73
74void DalObject::throw_init_ex(dunedaq::conffwk::Exception& ex)
75{
76 std::ostringstream text;
77 text << "failed to init " << this << ":\n\twas caused by: " << ex << std::endl;
78 p_was_read = false;
79 throw dunedaq::conffwk::Generic (ERS_HERE, text.str().c_str());
80}
81
82void DalObject::throw_get_ex(const std::string& what, const std::string& class_name, const DalObject * obj)
83{
84 std::ostringstream text;
85 text << "cannot find relationship or algorithm \"" << what << "\" in c++ class \"" << class_name << "\" for object " << obj;
86 throw dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str());
87}
88
89
90std::ostream&
91operator<<(std::ostream& s, const DalObject * obj)
92{
93 if (obj == nullptr)
95 else if (obj->is_deleted())
96 s << "(deleted object " << obj->UID() << '@' << obj->class_name() << ')';
97 else
98 s << '\'' << obj->UID() << '@' << obj->class_name() << '\'';
99
100 return s;
101}
102
103
104void
105p_sv_rel(std::ostream &s, const std::string &str, const std::string &name, const DalObject *obj)
106{
107 s << str << name << ": " << obj << '\n';
108}
109
110
111} // namespace conffwk
112
113} // namespace dunedaq
#define ERS_HERE
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
static void p_null(std::ostream &s)
print "(null)"
Definition DalObject.cpp:47
static void p_rm(std::ostream &s)
print "(deleted object)"
Definition DalObject.cpp:53
void throw_init_ex(dunedaq::conffwk::Exception &ex)
throw object initialisation exception (i.e.
Definition DalObject.cpp:74
const std::string & class_name() const 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
const std::string & UID() const noexcept
DalRegistry & p_registry
Configuration 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.
DalObject * get(ConfigObject &obj, bool upcast_unregistered=false)
Generic configuration exception.
void p_sv_rel(std::ostream &s, const std::string &str, const std::string &name, const DalObject *obj)
print weak single-value relationship
std::ostream & operator<<(std::ostream &, const ConfigurationChange &)
Including Qt Headers.