DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
src
internal
config_api_graph.cpp
Go to the documentation of this file.
1
// DUNE DAQ modification notice:
2
// This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
3
// Fork baseline commit: dbe-02-12-17 (2022-05-12).
4
// Renamed since fork: no.
5
6
/*
7
* config_api_graph.cpp
8
*
9
* Created on: Apr 20, 2016
10
* Author: Leonidas Georgopoulos
11
*/
12
13
#include "
dbe/config_api_graph.hpp
"
14
#include "
dbe/config_api_info.hpp
"
15
#include "
dbe/confobject_desc.hpp
"
16
#include "
dbe/dbcontroller.hpp
"
17
#include "
dbe/messenger.hpp
"
18
19
#include "
conffwk/Schema.hpp
"
20
21
#include <algorithm>
22
23
using namespace
dunedaq::conffwk
;
24
25
//------------------------------------------------------------------------------------------
26
// DBE::CONFIG::API::GRAPH NAMESPACE
27
//------------------------------------------------------------------------------------------
28
namespace
dbe
{
29
namespace
config
{
30
namespace
api
{
31
namespace
graph
{
32
33
//------------------------------------------------------------------------------------------
34
namespace
linked
{
35
namespace
through
{
36
//------------------------------------------------------------------------------------------
37
//------------------------------------------------------------------------------------------
38
/*
39
* Objects referenced by the given object through a specific attribute
40
*/
41
template
<>
42
tref
43
attribute<tref>
(
tref
object
,
dunedaq::conffwk::attribute_t
const
& attr)
44
{
45
return
object
.
get
<
tref
>(attr.
p_name
);
46
}
47
48
template
<>
49
std::vector<tref>
50
attribute<std::vector<tref>
>(
tref
item,
dunedaq::conffwk::attribute_t
const
& attr)
51
{
52
if
(attr.p_type ==
dunedaq::conffwk::class_type
) {
53
if
(attr.p_is_multi_value) {
54
std::vector<tref> adj;
55
item.get(attr.p_name, adj);
56
return
adj;
57
}
else
if
(attr.p_is_not_null) {
58
try
{
59
return
{
attribute<tref>
(item, attr) };
60
}
catch
(daq::dbe::config_object_retrieval_result_is_null
const
& e) {
61
if
(attr.p_is_not_null) {
62
WARN
(
"Query returned null value for an attr that has p_is_not_null set true"
,
63
"Program parsing data validation failure"
,
64
item.full_name(),
65
" for attribute "
,
66
attr.p_name);
67
}
else
{
68
DEBUG
(
"Query returned null value"
,
"Program parsing data validation"
);
69
}
70
}
71
}
72
}
73
74
return
{};
75
}
76
//------------------------------------------------------------------------------------------
77
78
//------------------------------------------------------------------------------------------
79
/*
80
* Objects referenced by the given object through a specific relation
81
*/
82
template
<>
83
tref
84
relation<tref>
(
tref
object
,
dunedaq::conffwk::relationship_t
const
& r)
85
{
86
return
object
.
get
<
tref
>(r.p_name);
87
}
88
89
template
<>
90
std::vector<tref>
91
relation<std::vector<tref>
>(
tref
item,
dunedaq::conffwk::relationship_t
const
& r)
92
{
93
if
(
dbe::config::api::info::relation::is_simple
(r)) {
94
try
{
95
return
{
through::relation<tref>
(item, r) };
96
}
catch
(daq::dbe::config_object_retrieval_result_is_null
const
& e) {
97
return
{};
98
}
99
}
else
{
100
std::vector<tref> adjacent;
101
item.get(r.p_name, adjacent);
102
return
adjacent;
103
}
104
}
105
106
template
<>
107
QStringList
108
relation<QStringList>
(
tref
item,
dunedaq::conffwk::relationship_t
const
& r)
109
{
110
QStringList result;
111
std::vector<tref> adjacent =
relation<std::vector<tref>
>(item, r);
112
113
for
(
auto
const
& x : adjacent) {
114
result.push_back(x.UID().c_str());
115
}
116
117
return
result;
118
}
119
120
template
<>
121
std::vector<dbe::config_object_description<std::string>>
122
relation<std::vector<dbe::config_object_description<std::string>
>>(
tref
object,
123
dunedaq::conffwk::relationship_t
const
&
relation
)
124
{
125
std::vector<dbe::config_object_description<std::string>> result;
126
127
std::vector<tref> adjacent =
linked::through::relation<std::vector<tref>
>(object,
relation
);
128
129
for
(
auto
const
& x : adjacent) {
130
result.push_back(x);
131
}
132
133
return
result;
134
}
135
136
//------------------------------------------------------------------------------------------
137
}
// end namespace through
138
}
// end namespace link
139
140
//------------------------------------------------------------------------------------------
141
template
<
typename
T>
142
inline
T
143
direct::linked
(
ConfigObject
& input,
dunedaq::conffwk::relationship_t
const
& relation)
144
{
145
T value;
146
input.
get
(relation.p_name, value);
147
return
value;
148
}
149
150
template
ConfigObject
151
direct::linked<ConfigObject>
(
ConfigObject
&,
dunedaq::conffwk::relationship_t
const
&);
152
153
template
std::vector<ConfigObject>
154
direct::linked<std::vector<ConfigObject>
>(
ConfigObject
&,
dunedaq::conffwk::relationship_t
const
&);
155
//------------------------------------------------------------------------------------------
156
157
//------------------------------------------------------------------------------------------
158
/*
159
* Retrieve objects referenced by an object through any of its relations
160
*/
161
template
<
typename
T>
162
std::vector<T>
163
linked::through::relations
(
inner::configobject::tref
const
& o)
164
{
165
dunedaq::conffwk::class_t
classdef{
info::onclass::definition
(o.
class_name
(),
false
) };
166
167
std::vector<T> voisins;
168
169
for
(
dunedaq::conffwk::relationship_t
const
& r : classdef.
p_relationships
) {
170
std::vector<T> a =
relation<std::vector<T>
>(o, r);
171
voisins.insert(voisins.end(), a.begin(), a.end());
172
}
173
174
voisins.erase(std::unique(std::begin(voisins), std::end(voisins)), std::end(voisins));
175
return
voisins;
176
}
177
template
std::vector<tref>
178
linked::through::relations<tref>
(
tref
const
&);
179
180
/*
181
* Retrieve objects linked by an object through any of its attributes
182
*/
183
template
<
typename
T>
184
std::vector<T>
185
linked::through::attributes
(
inner::configobject::tref
const
& o)
186
{
187
dunedaq::conffwk::class_t
classdef{
info::onclass::definition
(o.
class_name
(),
true
) };
188
189
std::vector<T> voisins;
190
191
for
(
dunedaq::conffwk::attribute_t
const
& attr : classdef.
p_attributes
) {
192
std::vector<tref> a =
attribute<std::vector<T>
>(o, attr);
193
voisins.insert(voisins.end(), a.begin(), a.end());
194
}
195
196
voisins.erase(std::unique(std::begin(voisins), std::end(voisins)), std::end(voisins));
197
return
voisins;
198
}
199
template
std::vector<tref>
200
linked::through::attributes<tref>
(
tref
const
&);
201
//------------------------------------------------------------------------------------------
202
203
//------------------------------------------------------------------------------------------
204
/*
205
* Retrieve links by operating directly on a ConfigObject
206
*/
207
template
<
typename
T>
208
inline
T
209
direct::linked
(
ConfigObject
& input,
dunedaq::conffwk::attribute_t
const
& relation)
210
{
211
T value;
212
input.
get
(relation.p_name, value);
213
return
value;
214
}
215
216
template
<>
217
inline
QStringList
218
direct::linked<QStringList>
(
ConfigObject
& input,
dunedaq::conffwk::relationship_t
const
& relation)
219
{
220
QStringList result;
221
std::vector<ConfigObject> adjacent;
222
223
if
(
info::relation::is_simple
(relation)) {
224
adjacent = {
direct::linked<ConfigObject>
(input, relation) };
225
}
else
{
226
adjacent =
direct::linked<std::vector<ConfigObject>
>(input, relation);
227
}
228
229
for
(
auto
const
& x : adjacent) {
230
result.push_back(x.UID().c_str());
231
}
232
233
return
result;
234
}
235
236
template
ConfigObject
237
direct::linked<ConfigObject>
(
ConfigObject
&,
dunedaq::conffwk::attribute_t
const
&);
238
template
std::vector<ConfigObject>
239
direct::linked<std::vector<ConfigObject>
>(
ConfigObject
&,
dunedaq::conffwk::attribute_t
const
&);
240
template
QStringList
241
direct::linked<QStringList>
(
ConfigObject
&,
dunedaq::conffwk::relationship_t
const
&);
242
//------------------------------------------------------------------------------------------
243
244
template
tref
245
linked::through::attribute<tref>
(
inner::configobject::tref
,
dunedaq::conffwk::attribute_t
const
&);
246
template
std::vector<tref>
247
linked::through::attribute<std::vector<tref>
>(
inner::configobject::tref
,
dunedaq::conffwk::attribute_t
const
&);
248
template
tref
249
linked::through::relation<tref>
(
tref
,
dunedaq::conffwk::relationship_t
const
&);
250
template
std::vector<tref>
251
linked::through::relation<std::vector<tref>
>(
tref
,
dunedaq::conffwk::relationship_t
const
&);
252
template
QStringList
253
linked::through::relation<QStringList>
(
tref
,
dunedaq::conffwk::relationship_t
const
&);
254
template
std::vector<dbe::config_object_description<std::string>>
255
linked::through::relation<std::vector<dbe::config_object_description<std::string>
>>(
256
dbe::inner::configobject::tref
,
257
dunedaq::conffwk::relationship_t
const
&);
258
//------------------------------------------------------------------------------------------
259
260
//------------------------------------------------------------------------------------------
261
namespace
linked
{
262
namespace
by {
263
/*
264
* Get objects that are linked by a given object
265
*/
266
template
<
typename
T>
267
std::vector<T>
268
object
(
inner::configobject::tref
const
& o)
269
{
270
std::vector<T> links =
through::attributes<T>
(o);
271
std::vector<T> rlinks =
through::relations<T>
(o);
272
273
if
(not rlinks.empty()) {
274
links.insert(links.end(), rlinks.begin(), rlinks.end());
275
}
276
277
links.erase(std::unique(links.begin(), links.end()), links.end());
278
279
return
links;
280
}
281
282
}
// end namespace by
283
}
// end namespace link
284
template
std::vector<inner::configobject::tref>
285
linked::by::object<inner::configobject::tref>
(
inner::configobject::tref
const
&);
286
//------------------------------------------------------------------------------------------
287
288
//------------------------------------------------------------------------------------------
289
namespace
linked
{
290
namespace
to
{
291
292
/*
293
* Get objects which link to a given object
294
*/
295
template
<>
296
std::vector<inner::configobject::tref>
297
object<inner::configobject::tref>
(
inner::configobject::tref
const
& o)
298
{
299
// Use with caution ... takes for ever to complete due to the underlying
300
// ConfigObject implementation
301
return
o.
referenced_by
(
"*"
,
false
);
302
}
303
304
}
// end namespace to
305
}
// end namespace link
306
template
std::vector<inner::configobject::tref>
307
linked::to::object<inner::configobject::tref>
(
inner::configobject::tref
const
&);
308
//------------------------------------------------------------------------------------------
309
}
310
}
311
}
312
}
313
//------------------------------------------------------------------------------------------
dbe::config::api::graph::direct::linked
static T linked(dunedaq::conffwk::ConfigObject &item, dunedaq::conffwk::relationship_t const &relation)
Definition
config_api_graph.cpp:143
dbe::config::api::info::onclass::definition
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
Definition
config_api_info.cpp:102
dbe::inner::configobject::ref_interface::get
U get(std::string const &key)
Definition
config_reference.hpp:193
dbe::inner::configobject::ref_interface::class_name
std::string class_name() const
Definition
config_reference.hpp:180
dbe::inner::configobject::ref_interface::referenced_by
std::vector< T > referenced_by(std::string const &name="*", bool check_composite_only=true) const
Definition
dbcontroller.cpp:34
dbe::inner::configobject::tref
Definition
config_reference.hpp:416
dunedaq::conffwk::ConfigObject
Represents database objects.
Definition
ConfigObject.hpp:54
dunedaq::conffwk::ConfigObject::get
void get(const std::string &name, T &value)
Get value of object's attribute or relationship.
Definition
ConfigObject.hpp:259
Schema.hpp
config_api_graph.hpp
config_api_info.hpp
confobject_desc.hpp
dbcontroller.hpp
messenger.hpp
WARN
#define WARN(...)
Definition
messenger.hpp:82
DEBUG
#define DEBUG(...)
Definition
messenger.hpp:121
dbe::config::api::graph::linked::by::object
std::vector< T > object(tref const &item)
Definition
config_api_graph.cpp:268
dbe::config::api::graph::linked::through
Definition
config_api_graph.hpp:86
dbe::config::api::graph::linked::through::relation< QStringList >
QStringList relation< QStringList >(tref item, dunedaq::conffwk::relationship_t const &r)
Definition
config_api_graph.cpp:108
dbe::config::api::graph::linked::through::attributes
std::vector< T > attributes(tref const &item)
Definition
config_api_graph.cpp:185
dbe::config::api::graph::linked::through::attribute
T attribute(tref item, dunedaq::conffwk::attribute_t const &attr)
dbe::config::api::graph::linked::through::relation< tref >
tref relation< tref >(tref object, dunedaq::conffwk::relationship_t const &r)
Definition
config_api_graph.cpp:84
dbe::config::api::graph::linked::through::attribute< tref >
tref attribute< tref >(tref object, dunedaq::conffwk::attribute_t const &attr)
Definition
config_api_graph.cpp:43
dbe::config::api::graph::linked::through::relation
T relation(tref item, dunedaq::conffwk::relationship_t const &relation)
dbe::config::api::graph::linked::through::relations
std::vector< T > relations(tref const &item)
Definition
config_api_graph.cpp:163
dbe::config::api::graph::linked::to::object< inner::configobject::tref >
std::vector< inner::configobject::tref > object< inner::configobject::tref >(inner::configobject::tref const &o)
Definition
config_api_graph.cpp:297
dbe::config::api::graph::linked
Definition
config_api_graph.hpp:46
dbe::config::api::graph
Definition
config_api_graph.hpp:44
dbe::config::api::graph::object< inner::configobject::tref >
template std::vector< inner::configobject::tref > linked::by::object< inner::configobject::tref >(inner::configobject::tref const &)
dbe::config::api::info::relation::is_simple
bool is_simple(dunedaq::conffwk::relationship_t const &)
Definition
config_api_info.cpp:132
dbe::config::api
Definition
config_api.hpp:30
dbe::config
Definition
config_api.hpp:29
dbe
Include QT Headers.
Definition
BatchChangeWidget.hpp:16
dbe::tref
inner::configobject::tref tref
Definition
tref.hpp:36
dunedaq::conffwk
Definition
test_circular_dependency.hpp:5
dunedaq::conffwk::class_type
@ class_type
Definition
Schema.hpp:44
dunedaq::to
Both frame_count_limit and tp_count_limit were set to(disabled) in the TPCRawDataProcessor " "config. TPs will not send."
dunedaq::conffwk::attribute_t
Definition
Schema.hpp:60
dunedaq::conffwk::attribute_t::p_name
std::string p_name
Definition
Schema.hpp:62
dunedaq::conffwk::class_t
Definition
Schema.hpp:153
dunedaq::conffwk::class_t::p_attributes
const std::vector< attribute_t > p_attributes
Definition
Schema.hpp:161
dunedaq::conffwk::class_t::p_relationships
const std::vector< relationship_t > p_relationships
Definition
Schema.hpp:162
dunedaq::conffwk::relationship_t
Definition
Schema.hpp:117
Generated on
for DUNE-DAQ by
1.18.0