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 "
conffwk/Schema.hpp
"
15
#include "
dbe/Sorting.hpp
"
16
#include "
dbe/config_api.hpp
"
17
#include "
dbe/treenode.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
namespace
config
{
28
namespace
api
{
29
namespace
info
{
30
//------------------------------------------------------------------------------------------
31
template
<>
32
std::vector<dbe::tref>
33
onclass::objects<true>
(std::string
const
& cname,
bool
const
keep_inherited)
34
{
35
std::vector<dbe::tref> objectrefs =
inner::dbcontroller::gets
(cname);
36
37
if
(not keep_inherited) {
38
objectrefs.erase(std::remove_if(objectrefs.begin(),
39
objectrefs.end(),
40
[&cname](
dbe::tref
anobject) { return (anobject.class_name() != cname); }),
41
objectrefs.end());
42
}
43
44
std::sort(objectrefs.begin(), objectrefs.end(),
SortObjects
());
45
46
return
objectrefs;
47
}
48
template
std::vector<dbe::tref>
49
onclass::objects<true>
(std::string
const
&,
bool
const
);
50
51
template
<>
52
std::vector<dbe::tref>
53
onclass::objects<false>
(std::string
const
& cname,
bool
const
keep_inherited)
54
{
55
std::vector<dbe::tref> objectrefs =
inner::dbcontroller::gets
(cname);
56
57
if
(not keep_inherited) {
58
objectrefs.erase(std::remove_if(objectrefs.begin(),
59
objectrefs.end(),
60
[&cname](
dbe::tref
anobject) { return (anobject.class_name() != cname); }),
61
objectrefs.end());
62
}
63
64
return
objectrefs;
65
}
66
template
std::vector<dbe::tref>
67
onclass::objects<false>
(std::string
const
&,
bool
const
);
68
//------------------------------------------------------------------------------------------
69
70
//------------------------------------------------------------------------------------------
71
bool
72
onclass::derived
(std::string
const
& fromclass, std::string
const
& aclass)
73
{
74
dunedaq::conffwk::class_t
aclassdef{
dbe::config::api::info::onclass::definition
(aclass,
false
) };
75
76
for
(std::string
const
& x : aclassdef.
p_superclasses
) {
77
if
(fromclass == x) {
78
return
true
;
79
}
80
}
81
82
return
false
;
83
}
84
//------------------------------------------------------------------------------------------
85
86
//------------------------------------------------------------------------------------------
87
bool
88
has_obj
(std::string
const
& classname, std::string
const
& object_uid)
89
{
90
try
{
91
return
not
inner::dbcontroller::get
({ object_uid,
classname
}).is_null();
92
}
catch
(daq::dbe::config_object_retrieval_result_is_null
const
& e) {
93
return
false
;
94
}
95
96
return
true
;
97
}
98
//------------------------------------------------------------------------------------------
99
100
//------------------------------------------------------------------------------------------
101
dunedaq::conffwk::class_t
102
onclass::definition
(
const
std::string& cn,
bool
direct_only)
103
{
104
try
{
105
return
dbaccessor::dbptr
()->get_class_info(cn, direct_only);
106
}
catch
(dunedaq::conffwk::NotFound
const
& Ex) {
107
return
dunedaq::conffwk::class_t
();
108
}
109
}
110
//------------------------------------------------------------------------------------------
111
112
//------------------------------------------------------------------------------------------
113
dunedaq::conffwk::attribute_t
114
attributematch
(QString
const
& AttributeName, QString
const
& ClassName)
115
{
116
const
dunedaq::conffwk::class_t
& ClassInfo =
117
dbe::config::api::info::onclass::definition
(ClassName.toStdString(),
false
);
118
const
std::vector<dunedaq::conffwk::attribute_t> AttributeList = ClassInfo.
p_attributes
;
119
120
for
(
auto
& Attribute : AttributeList) {
121
if
(Attribute.p_name == AttributeName.toStdString()) {
122
return
Attribute;
123
}
124
}
125
126
return
dunedaq::conffwk::attribute_t
();
127
}
128
//------------------------------------------------------------------------------------------
129
130
//------------------------------------------------------------------------------------------
131
bool
132
relation::is_simple
(
dunedaq::conffwk::relationship_t
const
&
relation
)
133
{
134
return
(
relation
.p_cardinality ==
dunedaq::conffwk::only_one
) or
135
(
relation
.p_cardinality ==
dunedaq::conffwk::zero_or_one
);
136
}
137
//------------------------------------------------------------------------------------------
138
139
//------------------------------------------------------------------------------------------
140
template
<>
141
dunedaq::conffwk::relationship_t
142
info::relation::match<std::string>
(std::string
const
& arelation, std::string
const
& aclass)
143
{
144
dunedaq::conffwk::class_t
const
& aninfo_for_class =
dbe::config::api::info::onclass::definition
(aclass,
false
);
145
std::vector<dunedaq::conffwk::relationship_t>
const
relations = aninfo_for_class.
p_relationships
;
146
147
for
(
auto
& r : relations) {
148
if
(r.p_name == arelation) {
149
return
r;
150
}
151
}
152
return
dunedaq::conffwk::relationship_t
();
153
}
154
template
dunedaq::conffwk::relationship_t
155
info::relation::match<std::string>
(std::string
const
&, std::string
const
&);
156
//------------------------------------------------------------------------------------------
157
158
//------------------------------------------------------------------------------------------
159
template
<>
160
dunedaq::conffwk::relationship_t
161
info::relation::match<QString>
(QString
const
& arelation, QString
const
& aclass)
162
{
163
return
match(aclass.toStdString(), arelation.toStdString());
164
}
165
template
dunedaq::conffwk::relationship_t
166
info::relation::match<QString>
(QString
const
&, QString
const
&);
167
//------------------------------------------------------------------------------------------
168
}
169
}
170
}
171
}
172
//------------------------------------------------------------------------------------------
Sorting.hpp
dbe::SortObjects
Definition
Sorting.hpp:16
dbe::config::api::info::onclass::derived
static bool derived(std::string const &fromclass, std::string const &aclass)
Definition
config_api_info.cpp:72
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:102
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:363
dbe::inner::dbcontroller::get
static configobject::tref get(dbe::cokey const &desc)
Definition
dbcontroller.cpp:357
Schema.hpp
config_api.hpp
config_api_info.hpp
dbe::config::api::info::relation
Definition
config_api_info.hpp:51
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:132
dbe::config::api::info
Definition
config_api.hpp:31
dbe::config::api::info::has_obj
bool has_obj(std::string const &classname, std::string const &object_uid)
Definition
config_api_info.cpp:88
dbe::config::api::info::attributematch
dunedaq::conffwk::attribute_t attributematch(QString const &, QString const &)
Definition
config_api_info.cpp:114
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::only_one
@ only_one
Definition
Schema.hpp:110
dunedaq::conffwk::zero_or_one
@ zero_or_one
Definition
Schema.hpp:108
dunedaq::conffwk::attribute_t
Definition
Schema.hpp:60
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::class_t::p_superclasses
const std::vector< std::string > p_superclasses
Definition
Schema.hpp:159
dunedaq::conffwk::relationship_t
Definition
Schema.hpp:117
treenode.hpp
tablepositions::classname
@ classname
Definition
ui_constants.hpp:11
Generated on
for DUNE-DAQ by
1.18.0