DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
src
internal
config_api_set.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_set.cpp
8
*
9
* Created on: Apr 19, 2016
10
* Author: Leonidas Georgopoulos
11
*/
12
13
#include "
dbe/config_api_set.hpp
"
14
#include "
dbe/Conversion.hpp
"
15
#include "
dbe/config_api.hpp
"
16
#include "
dbe/config_api_commands.hpp
"
17
#include "
dbe/config_api_info.hpp
"
18
#include "
dbe/config_object_key.hpp
"
19
#include "
dbe/dbcontroller.hpp
"
20
21
#include "
conffwk/Schema.hpp
"
22
23
#include <QString>
24
25
#include <algorithm>
26
#include <iterator>
27
#include <stdint.h>
28
#include <sys/types.h>
29
30
//------------------------------------------------------------------------------------------
31
// NAMESPACE DBE::CONFIG::API::SET::NOACTIONS
32
//------------------------------------------------------------------------------------------
33
namespace
dbe
{
34
namespace
config
{
35
namespace
api
{
36
namespace
set
{
37
namespace
noactions
{
38
39
void
40
relation
(
tref
object
,
dunedaq::conffwk::relationship_t
const
& arelation, std::vector<dbe::cokey>
const
& keys)
41
{
42
std::vector<dbe::inner::configobject::tref> trefs;
43
44
for
(
dbe::cokey
const
& key : keys) {
45
trefs.push_back(
dbe::inner::dbcontroller::get
(key));
46
}
47
48
dbe::config::api::set::noactions::relation
(
object
, arelation, trefs);
49
}
50
51
void
52
relation
(
tref
src,
dunedaq::conffwk::relationship_t
const
& edge, std::vector<tref>
const
& targets)
53
{
54
try
{
55
if
(not targets.empty()) {
56
if
(
info::relation::is_simple
(edge)) {
57
src.
set_obj
(edge.
p_name
, targets.back());
58
}
else
{
59
src.
set_objs
(edge.
p_name
, targets);
60
}
61
}
else
{
62
src.
set_obj_null
(edge.
p_name
,
info::relation::is_simple
(edge));
63
}
64
}
catch
(dunedaq::conffwk::Exception
const
& e) {
65
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
,
config::errors::parse
(e));
66
}
67
}
68
//------------------------------------------------------------------------------------------
69
}
70
}
71
}
72
}
73
}
74
//------------------------------------------------------------------------------------------
75
76
//------------------------------------------------------------------------------------------
77
// NAMESPACE DBE::CONFIG::API::SET
78
//------------------------------------------------------------------------------------------
79
namespace
dbe
{
80
namespace
config
{
81
namespace
api
{
82
namespace
set
{
83
84
//------------------------------------------------------------------------------------------
85
void
86
relation
(
tref
src,
dunedaq::conffwk::relationship_t
const
& edge, QStringList
const
& targets)
87
{
88
std::vector<std::string> targetnames;
89
90
for
(QString
const
& name : targets) {
91
targetnames.push_back(name.toStdString());
92
}
93
94
commands::modobj
(src, edge, targetnames);
95
}
96
//------------------------------------------------------------------------------------------
97
98
//------------------------------------------------------------------------------------------
99
void
100
attribute
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& attribute_info, QStringList
const
& values)
101
{
102
switch
(attribute_info.
p_type
) {
103
case
dunedaq::conffwk::bool_type
: {
104
if
(attribute_info.
p_is_multi_value
) {
105
commands::modobj
(Object, attribute_info,
convert::to
<std::vector<bool>>(values, attribute_info.
p_int_format
));
106
}
else
{
107
commands::modobj
(Object, attribute_info,
convert::to<bool>
(values, attribute_info.
p_int_format
));
108
}
109
110
break
;
111
}
112
113
case
dunedaq::conffwk::enum_type
:
114
case
dunedaq::conffwk::date_type
:
115
case
dunedaq::conffwk::time_type
:
116
case
dunedaq::conffwk::string_type
:
117
case
dunedaq::conffwk::class_type
: {
118
if
(attribute_info.
p_is_multi_value
) {
119
commands::modobj
(Object, attribute_info,
convert::to
<std::vector<std::string>>(values));
120
}
else
{
121
commands::modobj
(Object, attribute_info,
convert::to<std::string>
(values));
122
}
123
124
break
;
125
}
126
127
case
dunedaq::conffwk::float_type
: {
128
if
(attribute_info.
p_is_multi_value
) {
129
commands::modobj
(Object, attribute_info,
convert::to
<std::vector<float>>(values, attribute_info.
p_int_format
));
130
}
else
{
131
commands::modobj
(Object, attribute_info,
convert::to<float>
(values, attribute_info.
p_int_format
));
132
}
133
134
break
;
135
}
136
137
case
dunedaq::conffwk::double_type
: {
138
if
(attribute_info.
p_is_multi_value
) {
139
commands::modobj
(Object, attribute_info,
convert::to
<std::vector<double>>(values, attribute_info.
p_int_format
));
140
}
else
{
141
commands::modobj
(Object, attribute_info,
convert::to<double>
(values, attribute_info.
p_int_format
));
142
}
143
144
break
;
145
}
146
147
case
dunedaq::conffwk::s8_type
: {
148
if
(attribute_info.
p_is_multi_value
) {
149
commands::modobj
(Object, attribute_info,
convert::to
<std::vector<int8_t>>(values, attribute_info.
p_int_format
));
150
}
else
{
151
commands::modobj
(Object, attribute_info,
convert::to<int8_t>
(values, attribute_info.
p_int_format
));
152
}
153
154
break
;
155
}
156
157
case
dunedaq::conffwk::s16_type
: {
158
if
(attribute_info.
p_is_multi_value
) {
159
commands::modobj
(
160
Object, attribute_info,
convert::to
<std::vector<int16_t>>(values, attribute_info.
p_int_format
));
161
}
else
{
162
commands::modobj
(Object, attribute_info,
convert::to<int16_t>
(values, attribute_info.
p_int_format
));
163
}
164
165
break
;
166
}
167
168
case
dunedaq::conffwk::s32_type
: {
169
if
(attribute_info.
p_is_multi_value
) {
170
commands::modobj
(
171
Object, attribute_info,
convert::to
<std::vector<int32_t>>(values, attribute_info.
p_int_format
));
172
}
else
{
173
commands::modobj
(Object, attribute_info,
convert::to<int32_t>
(values, attribute_info.
p_int_format
));
174
}
175
176
break
;
177
}
178
179
case
dunedaq::conffwk::s64_type
: {
180
if
(attribute_info.
p_is_multi_value
) {
181
commands::modobj
(
182
Object, attribute_info,
convert::to
<std::vector<int64_t>>(values, attribute_info.
p_int_format
));
183
}
else
{
184
commands::modobj
(Object, attribute_info,
convert::to<int64_t>
(values, attribute_info.
p_int_format
));
185
}
186
187
break
;
188
}
189
190
case
dunedaq::conffwk::u8_type
: {
191
if
(attribute_info.
p_is_multi_value
) {
192
commands::modobj
(
193
Object, attribute_info,
convert::to
<std::vector<u_int8_t>>(values, attribute_info.
p_int_format
));
194
}
else
{
195
commands::modobj
(Object, attribute_info,
convert::to<u_int8_t>
(values, attribute_info.
p_int_format
));
196
}
197
198
break
;
199
}
200
201
case
dunedaq::conffwk::u16_type
: {
202
if
(attribute_info.
p_is_multi_value
) {
203
commands::modobj
(
204
Object, attribute_info,
convert::to
<std::vector<u_int16_t>>(values, attribute_info.
p_int_format
));
205
}
else
{
206
commands::modobj
(Object, attribute_info,
convert::to<u_int16_t>
(values, attribute_info.
p_int_format
));
207
}
208
209
break
;
210
}
211
212
case
dunedaq::conffwk::u32_type
: {
213
if
(attribute_info.
p_is_multi_value
) {
214
commands::modobj
(
215
Object, attribute_info,
convert::to
<std::vector<u_int32_t>>(values, attribute_info.
p_int_format
));
216
}
else
{
217
commands::modobj
(Object, attribute_info,
convert::to<u_int32_t>
(values, attribute_info.
p_int_format
));
218
}
219
220
break
;
221
}
222
223
case
dunedaq::conffwk::u64_type
: {
224
if
(attribute_info.
p_is_multi_value
)
225
commands::modobj
(
226
Object, attribute_info,
convert::to
<std::vector<u_int64_t>>(values, attribute_info.
p_int_format
));
227
else
228
commands::modobj
(Object, attribute_info,
convert::to<u_int64_t>
(values, attribute_info.
p_int_format
));
229
230
break
;
231
}
232
233
default
:
234
break
;
235
}
236
}
237
//------------------------------------------------------------------------------------------
238
}
239
}
240
}
241
}
242
//------------------------------------------------------------------------------------------
Conversion.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:127
dbe::inner::configobject::ref_interface::set_objs
void set_objs(std::string const &name, std::vector< T > const &others, bool skip_non_null_check=false)
Definition
config_reference.hpp:235
dbe::inner::configobject::ref_interface::set_obj_null
void set_obj_null(std::string const &name, bool is_simple, bool skip_non_null_check=false)
Definition
config_reference.hpp:220
dbe::inner::configobject::ref_interface::set_obj
void set_obj(std::string const &name, T const &other, bool skip_non_null_check=false)
Definition
config_reference.hpp:229
dbe::inner::dbcontroller::get
static configobject::tref get(dbe::cokey const &desc)
Definition
dbcontroller.cpp:357
Schema.hpp
config_api.hpp
config_api_commands.hpp
config_api_info.hpp
config_api_set.hpp
config_object_key.hpp
dbcontroller.hpp
dbe::config::api::commands::modobj
void modobj(tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T Value)
Definition
config_api.hpp:97
dbe::config::api::info::relation::is_simple
bool is_simple(dunedaq::conffwk::relationship_t const &)
Definition
config_api_info.cpp:132
dbe::config::api::set::noactions
Definition
config_api_set.hpp:73
dbe::config::api::set::noactions::relation
void relation(dbe::inner::configobject::tref src, dunedaq::conffwk::relationship_t const &edge, std::vector< dbe::inner::configobject::tref > const &targets)
dbe::config::api::set
Definition
config_api_set.hpp:44
dbe::config::api::set::relation
void relation(dbe::inner::configobject::tref src, dunedaq::conffwk::relationship_t const &edge, QStringList const &targets)
Definition
config_api_set.cpp:86
dbe::config::api::set::attribute
void attribute(dbe::inner::configobject::tref objectref, dunedaq::conffwk::attribute_t const &attribute_info, QStringList const &attribute_values)
Definition
config_api_set.cpp:100
dbe::config::api
Definition
config_api.hpp:30
dbe::config::errors::parse
std::string const parse(ers::Issue const &)
Definition
config_api.cpp:98
dbe::config
Definition
config_api.hpp:29
dbe::convert::to
T to(QStringList const &DataList)
Definition
Conversion.hpp:114
dbe
Include QT Headers.
Definition
BatchChangeWidget.hpp:16
dbe::tref
inner::configobject::tref tref
Definition
tref.hpp:36
dbe::cokey
config_object_key cokey
Definition
config_object_key.hpp:36
dunedaq::conffwk::date_type
@ date_type
Definition
Schema.hpp:40
dunedaq::conffwk::u64_type
@ u64_type
Definition
Schema.hpp:37
dunedaq::conffwk::float_type
@ float_type
Definition
Schema.hpp:38
dunedaq::conffwk::s32_type
@ s32_type
Definition
Schema.hpp:34
dunedaq::conffwk::string_type
@ string_type
Definition
Schema.hpp:42
dunedaq::conffwk::s16_type
@ s16_type
Definition
Schema.hpp:32
dunedaq::conffwk::u32_type
@ u32_type
Definition
Schema.hpp:35
dunedaq::conffwk::enum_type
@ enum_type
Definition
Schema.hpp:43
dunedaq::conffwk::bool_type
@ bool_type
Definition
Schema.hpp:29
dunedaq::conffwk::class_type
@ class_type
Definition
Schema.hpp:44
dunedaq::conffwk::s8_type
@ s8_type
Definition
Schema.hpp:30
dunedaq::conffwk::time_type
@ time_type
Definition
Schema.hpp:41
dunedaq::conffwk::u8_type
@ u8_type
Definition
Schema.hpp:31
dunedaq::conffwk::s64_type
@ s64_type
Definition
Schema.hpp:36
dunedaq::conffwk::double_type
@ double_type
Definition
Schema.hpp:39
dunedaq::conffwk::u16_type
@ u16_type
Definition
Schema.hpp:33
dunedaq::conffwk::attribute_t
Definition
Schema.hpp:60
dunedaq::conffwk::attribute_t::p_int_format
int_format_t p_int_format
Definition
Schema.hpp:66
dunedaq::conffwk::attribute_t::p_is_multi_value
bool p_is_multi_value
Definition
Schema.hpp:68
dunedaq::conffwk::attribute_t::p_type
type_t p_type
Definition
Schema.hpp:63
dunedaq::conffwk::relationship_t
Definition
Schema.hpp:117
dunedaq::conffwk::relationship_t::p_name
std::string p_name
Definition
Schema.hpp:119
Generated on
for DUNE-DAQ by
1.18.0