DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
conffwk
src
DalObject.cpp
Go to the documentation of this file.
1
#include "
conffwk/DalObject.hpp
"
2
3
namespace
dunedaq
{
4
namespace
conffwk
{
5
6
7
bool
8
DalObject::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
24
bool
25
DalObject::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
46
void
47
DalObject::p_null
(std::ostream &s)
48
{
49
s <<
"(null)"
;
50
}
51
52
void
53
DalObject::p_rm
(std::ostream &s)
54
{
55
s <<
"(deleted object)"
;
56
}
57
58
void
59
DalObject::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
64
void
65
DalObject::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
74
void
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
82
void
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
90
std::ostream&
91
operator<<
(std::ostream& s,
const
DalObject
*
obj
)
92
{
93
if
(
obj
==
nullptr
)
94
DalObject::p_null
(s);
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
104
void
105
p_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
DalObject.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
dunedaq::conffwk::DalObject
The base class for any generated DAL object.
Definition
DalObject.hpp:52
dunedaq::conffwk::DalObject::p_hdr
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
dunedaq::conffwk::DalObject::p_null
static void p_null(std::ostream &s)
print "(null)"
Definition
DalObject.cpp:47
dunedaq::conffwk::DalObject::p_rm
static void p_rm(std::ostream &s)
print "(deleted object)"
Definition
DalObject.cpp:53
dunedaq::conffwk::DalObject::throw_init_ex
void throw_init_ex(dunedaq::conffwk::Exception &ex)
throw object initialisation exception (i.e.
Definition
DalObject.cpp:74
dunedaq::conffwk::DalObject::class_name
const std::string & class_name() const noexcept
Definition
DalObject.hpp:144
dunedaq::conffwk::DalObject::p_error
static void p_error(std::ostream &s, dunedaq::conffwk::Exception &ex)
print error text
Definition
DalObject.cpp:59
dunedaq::conffwk::DalObject::get_rel_objects
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
dunedaq::conffwk::DalObject::throw_get_ex
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
dunedaq::conffwk::DalObject::DalObject
DalObject(DalRegistry &db, const ConfigObject &o) noexcept
Definition
DalObject.hpp:67
dunedaq::conffwk::DalObject::UID
const std::string & UID() const noexcept
Definition
DalObject.hpp:135
dunedaq::conffwk::DalObject::p_registry
DalRegistry & p_registry
Configuration object.
Definition
DalObject.hpp:121
dunedaq::conffwk::DalObject::p_was_read
bool p_was_read
is true, if the object was read
Definition
DalObject.hpp:118
dunedaq::conffwk::DalObject::get_algo_objects
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
dunedaq::conffwk::DalObject::p_obj
ConfigObject p_obj
Config object used by given template object.
Definition
DalObject.hpp:124
conffwk.ConfigObject
Definition
ConfigObject.py:1
dunedaq::conffwk
Definition
Change.hpp:23
dunedaq::conffwk::p_sv_rel
void p_sv_rel(std::ostream &s, const std::string &str, const std::string &name, const DalObject *obj)
print weak single-value relationship
Definition
DalObject.cpp:105
dunedaq::conffwk::operator<<
std::ostream & operator<<(std::ostream &, const ConfigurationChange &)
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::obj
msgpack::object obj
Definition
Serialization.hpp:257
Generated on
for DUNE-DAQ by
1.17.0