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