DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
src
internal
config_api_info.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_info.cpp
8
*
9
* Created on: Apr 20, 2016
10
* Author: Leonidas Georgopoulos
11
*/
12
13
#include "
dbe/config_api_info.hpp
"
14
#include "
dbe/config_api.hpp
"
15
#include "
dbe/treenode.hpp
"
16
#include "
dbe/Sorting.hpp
"
17
#include "
conffwk/Schema.hpp
"
18
#include <QString>
19
//------------------------------------------------------------------------------------------
20
// DBE::CONFIG::API::INFO NAMESPACE
21
//------------------------------------------------------------------------------------------
22
/*
23
* This namespace groups methods for providing information about config related
24
* structures and objects
25
*/
26
namespace
dbe
27
{
28
namespace
config
29
{
30
namespace
api
31
{
32
namespace
info
33
{
34
//------------------------------------------------------------------------------------------
35
template
<>
36
std::vector<dbe::tref>
onclass::objects<true>
( std::string
const
& cname,
37
bool
const
keep_inherited )
38
{
39
std::vector<dbe::tref> objectrefs =
inner::dbcontroller::gets
( cname );
40
41
if
( not keep_inherited )
42
{
43
objectrefs.erase (
44
std::remove_if ( objectrefs.begin(), objectrefs.end(),
45
[&cname] (
dbe::tref
anobject )
46
{
47
return ( anobject.class_name() != cname );
48
} ),
49
objectrefs.end() );
50
}
51
52
std::sort ( objectrefs.begin(), objectrefs.end(),
SortObjects
() );
53
54
return
objectrefs;
55
}
56
template
std::vector<dbe::tref>
onclass::objects<true>
( std::string
const
&,
bool
const
);
57
58
template
<>
59
std::vector<dbe::tref>
onclass::objects<false>
( std::string
const
& cname,
60
bool
const
keep_inherited )
61
{
62
std::vector<dbe::tref> objectrefs =
inner::dbcontroller::gets
( cname );
63
64
if
( not keep_inherited )
65
{
66
objectrefs.erase (
67
std::remove_if ( objectrefs.begin(), objectrefs.end(),
68
[&cname] (
dbe::tref
anobject )
69
{
70
return ( anobject.class_name() != cname );
71
} ),
72
objectrefs.end() );
73
}
74
75
return
objectrefs;
76
}
77
template
std::vector<dbe::tref>
onclass::objects<false>
( std::string
const
&,
bool
const
);
78
//------------------------------------------------------------------------------------------
79
80
//------------------------------------------------------------------------------------------
81
bool
onclass::derived
( std::string
const
& fromclass, std::string
const
& aclass )
82
{
83
dunedaq::conffwk::class_t
aclassdef
84
{
dbe::config::api::info::onclass::definition
( aclass,
false
) };
85
86
for
( std::string
const
& x : aclassdef.
p_superclasses
)
87
{
88
if
( fromclass == x )
89
{
90
return
true
;
91
}
92
}
93
94
return
false
;
95
}
96
//------------------------------------------------------------------------------------------
97
98
//------------------------------------------------------------------------------------------
99
bool
has_obj
( std::string
const
&
classname
, std::string
const
& object_uid )
100
{
101
try
102
{
103
return
not
inner::dbcontroller::get
(
104
{ object_uid,
classname
} ).is_null();
105
}
106
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& e )
107
{
108
return
false
;
109
}
110
111
return
true
;
112
}
113
//------------------------------------------------------------------------------------------
114
115
//------------------------------------------------------------------------------------------
116
dunedaq::conffwk::class_t
onclass::definition
(
const
std::string & cn,
bool
direct_only )
117
{
118
try
119
{
120
return
dbaccessor::dbptr
()->get_class_info ( cn, direct_only );
121
}
122
catch
( dunedaq::conffwk::NotFound
const
& Ex )
123
{
124
return
dunedaq::conffwk::class_t
();
125
}
126
}
127
//------------------------------------------------------------------------------------------
128
129
//------------------------------------------------------------------------------------------
130
dunedaq::conffwk::attribute_t
attributematch
( QString
const
& AttributeName,
131
QString
const
& ClassName )
132
{
133
const
dunedaq::conffwk::class_t
& ClassInfo =
dbe::config::api::info::onclass::definition
(
134
ClassName.toStdString(),
false
);
135
const
std::vector<dunedaq::conffwk::attribute_t> AttributeList = ClassInfo.
p_attributes
;
136
137
for
(
auto
& Attribute : AttributeList )
138
{
139
if
( Attribute.p_name == AttributeName.toStdString() )
140
{
141
return
Attribute;
142
}
143
}
144
145
return
dunedaq::conffwk::attribute_t
();
146
}
147
//------------------------------------------------------------------------------------------
148
149
//------------------------------------------------------------------------------------------
150
bool
relation::is_simple
(
dunedaq::conffwk::relationship_t
const
&
relation
)
151
{
152
return
(
relation
.p_cardinality ==
dunedaq::conffwk::only_one
)
153
or (
relation
.p_cardinality ==
dunedaq::conffwk::zero_or_one
);
154
}
155
//------------------------------------------------------------------------------------------
156
157
//------------------------------------------------------------------------------------------
158
template
<>
dunedaq::conffwk::relationship_t
info::relation::match<std::string>
(
159
std::string
const
& arelation,
160
std::string
const
& aclass )
161
{
162
dunedaq::conffwk::class_t
const
& aninfo_for_class =
163
dbe::config::api::info::onclass::definition
( aclass,
false
);
164
std::vector<dunedaq::conffwk::relationship_t>
const
relations =
165
aninfo_for_class.
p_relationships
;
166
167
for
(
auto
& r : relations )
168
{
169
if
( r.p_name == arelation )
170
{
171
return
r;
172
}
173
}
174
return
dunedaq::conffwk::relationship_t
();
175
}
176
template
dunedaq::conffwk::relationship_t
info::relation::match<std::string>
(
177
std::string
const
& ,
178
std::string
const
& );
179
//------------------------------------------------------------------------------------------
180
181
//------------------------------------------------------------------------------------------
182
template
<>
dunedaq::conffwk::relationship_t
info::relation::match<QString>
(
183
QString
const
& arelation,
184
QString
const
& aclass )
185
{
186
return
match(aclass.toStdString(), arelation.toStdString());
187
}
188
template
dunedaq::conffwk::relationship_t
info::relation::match<QString>
(
189
QString
const
& ,
190
QString
const
& );
191
//------------------------------------------------------------------------------------------
192
}
193
}
194
}
195
}
196
//------------------------------------------------------------------------------------------
Sorting.hpp
dbe::SortObjects
Definition
Sorting.hpp:17
dbe::config::api::info::onclass::derived
static bool derived(std::string const &fromclass, std::string const &aclass)
Definition
config_api_info.cpp:81
dbe::config::api::info::onclass::objects
static std::vector< dbe::inner::configobject::tref > objects(std::string const &cname, bool const keep_inherited=true)
dbe::config::api::info::onclass::definition
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
Definition
config_api_info.cpp:116
dbe::dbaccessor::dbptr
static cptr< dunedaq::conffwk::Configuration > dbptr()
Definition
dbaccessor.cpp:23
dbe::inner::dbcontroller::gets
static std::vector< configobject::tref > gets(std::string const &cname, std::string const &query="")
Definition
dbcontroller.cpp:393
dbe::inner::dbcontroller::get
static configobject::tref get(dbe::cokey const &desc)
Definition
dbcontroller.cpp:388
Schema.hpp
config_api.hpp
config_api_info.hpp
dbe::config::api::info::relation
Definition
config_api_info.hpp:56
dbe::config::api::info::relation::match< QString >
dunedaq::conffwk::relationship_t match< QString >(QString const &, QString const &)
dbe::config::api::info::relation::match< std::string >
dunedaq::conffwk::relationship_t match< std::string >(std::string const &, std::string const &)
dbe::config::api::info::relation::is_simple
bool is_simple(dunedaq::conffwk::relationship_t const &)
Definition
config_api_info.cpp:150
dbe::config::api::info
Definition
config_api.hpp:35
dbe::config::api::info::has_obj
bool has_obj(std::string const &classname, std::string const &object_uid)
Definition
config_api_info.cpp:99
dbe::config::api::info::attributematch
dunedaq::conffwk::attribute_t attributematch(QString const &, QString const &)
Definition
config_api_info.cpp:130
dbe::config::api
Definition
config_api.hpp:33
dbe::config
Definition
config_api.hpp:31
dbe
Include QT Headers.
Definition
BatchChangeWidget.hpp:18
dbe::tref
inner::configobject::tref tref
Definition
tref.hpp:35
dunedaq::conffwk::only_one
@ only_one
Definition
Schema.hpp:113
dunedaq::conffwk::zero_or_one
@ zero_or_one
Definition
Schema.hpp:111
dunedaq::conffwk::attribute_t
Definition
Schema.hpp:59
dunedaq::conffwk::class_t
Definition
Schema.hpp:162
dunedaq::conffwk::class_t::p_attributes
const std::vector< attribute_t > p_attributes
Definition
Schema.hpp:170
dunedaq::conffwk::class_t::p_relationships
const std::vector< relationship_t > p_relationships
Definition
Schema.hpp:171
dunedaq::conffwk::class_t::p_superclasses
const std::vector< std::string > p_superclasses
Definition
Schema.hpp:168
dunedaq::conffwk::relationship_t
Definition
Schema.hpp:120
treenode.hpp
tablepositions::classname
@ classname
Definition
ui_constants.hpp:11
Generated on
for DUNE-DAQ by
1.17.0