DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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
15#include "dbe/config_api.hpp"
18#include "dbe/Conversion.hpp"
19#include "dbe/dbcontroller.hpp"
20
21#include "conffwk/Schema.hpp"
22
23#include <QString>
24
25#include <stdint.h>
26#include <sys/types.h>
27#include <algorithm>
28#include <iterator>
29
30//------------------------------------------------------------------------------------------
31// NAMESPACE DBE::CONFIG::API::SET::NOACTIONS
32//------------------------------------------------------------------------------------------
33namespace dbe
34{
35namespace config
36{
37namespace api
38{
39namespace set
40{
41namespace noactions
42{
43
44void relation ( tref object, dunedaq::conffwk::relationship_t const & arelation,
45 std::vector<dbe::cokey> const & keys )
46{
47 std::vector<dbe::inner::configobject::tref> trefs;
48
49 for ( dbe::cokey const & key : keys )
50 {
51 trefs.push_back ( dbe::inner::dbcontroller::get ( key ) );
52 }
53
54 dbe::config::api::set::noactions::relation ( object, arelation, trefs );
55}
56
58 std::vector<tref> const & targets )
59{
60 try
61 {
62 if ( not targets.empty() )
63 {
64 if ( info::relation::is_simple ( edge ) )
65 {
66 src.set_obj ( edge.p_name, targets.back() );
67 }
68 else
69 {
70 src.set_objs ( edge.p_name, targets );
71 }
72 }
73 else
74 {
76 }
77 }
78 catch ( dunedaq::conffwk::Exception const & e )
79 {
80 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, config::errors::parse ( e ) );
81 }
82}
83//------------------------------------------------------------------------------------------
84}
85}
86}
87}
88}
89//------------------------------------------------------------------------------------------
90
91//------------------------------------------------------------------------------------------
92// NAMESPACE DBE::CONFIG::API::SET
93//------------------------------------------------------------------------------------------
94namespace dbe
95{
96namespace config
97{
98namespace api
99{
100namespace set
101{
102
103//------------------------------------------------------------------------------------------
105 QStringList const & targets )
106{
107 std::vector<std::string> targetnames;
108
109 for ( QString const & name : targets )
110 {
111 targetnames.push_back ( name.toStdString() );
112 }
113
114 commands::modobj ( src, edge, targetnames );
115}
116//------------------------------------------------------------------------------------------
117
118//------------------------------------------------------------------------------------------
119void attribute ( tref Object, dunedaq::conffwk::attribute_t const & attribute_info,
120 QStringList const & values )
121{
122 switch ( attribute_info.p_type )
123 {
125 {
126 if ( attribute_info.p_is_multi_value )
127 {
129 Object, attribute_info,
130 convert::to<std::vector<bool>> ( values, attribute_info.p_int_format ) );
131 }
132 else
133 {
134 commands::modobj ( Object, attribute_info,
135 convert::to<bool> ( values, attribute_info.p_int_format ) );
136 }
137
138 break;
139 }
140
146 {
147 if ( attribute_info.p_is_multi_value )
148 {
149 commands::modobj ( Object, attribute_info,
150 convert::to<std::vector<std::string>> ( values ) );
151 }
152 else
153 {
154 commands::modobj ( Object, attribute_info, convert::to<std::string> ( values ) );
155 }
156
157 break;
158 }
159
161 {
162 if ( attribute_info.p_is_multi_value )
163 {
165 Object, attribute_info,
166 convert::to<std::vector<float>> ( values, attribute_info.p_int_format ) );
167 }
168 else
169 {
170 commands::modobj ( Object, attribute_info,
171 convert::to<float> ( values, attribute_info.p_int_format ) );
172 }
173
174 break;
175 }
176
178 {
179 if ( attribute_info.p_is_multi_value )
180 {
182 Object, attribute_info,
183 convert::to<std::vector<double>> ( values, attribute_info.p_int_format ) );
184 }
185 else
186 {
187 commands::modobj ( Object, attribute_info,
188 convert::to<double> ( values, attribute_info.p_int_format ) );
189 }
190
191 break;
192 }
193
195 {
196 if ( attribute_info.p_is_multi_value )
197 {
199 Object, attribute_info,
200 convert::to<std::vector<int8_t>> ( values, attribute_info.p_int_format ) );
201 }
202 else
203 {
204 commands::modobj ( Object, attribute_info,
205 convert::to<int8_t> ( values, attribute_info.p_int_format ) );
206 }
207
208 break;
209 }
210
212 {
213 if ( attribute_info.p_is_multi_value )
214 {
216 Object, attribute_info,
217 convert::to<std::vector<int16_t>> ( values, attribute_info.p_int_format ) );
218 }
219 else
220 {
221 commands::modobj ( Object, attribute_info,
222 convert::to<int16_t> ( values, attribute_info.p_int_format ) );
223 }
224
225 break;
226 }
227
229 {
230 if ( attribute_info.p_is_multi_value )
231 {
233 Object, attribute_info,
234 convert::to<std::vector<int32_t>> ( values, attribute_info.p_int_format ) );
235 }
236 else
237 {
238 commands::modobj ( Object, attribute_info,
239 convert::to<int32_t> ( values, attribute_info.p_int_format ) );
240 }
241
242 break;
243 }
244
246 {
247 if ( attribute_info.p_is_multi_value )
248 {
250 Object, attribute_info,
251 convert::to<std::vector<int64_t>> ( values, attribute_info.p_int_format ) );
252 }
253 else
254 {
255 commands::modobj ( Object, attribute_info,
256 convert::to<int64_t> ( values, attribute_info.p_int_format ) );
257 }
258
259 break;
260 }
261
263 {
264 if ( attribute_info.p_is_multi_value )
265 {
267 Object, attribute_info,
268 convert::to<std::vector<u_int8_t>> ( values, attribute_info.p_int_format ) );
269 }
270 else
271 {
272 commands::modobj ( Object, attribute_info,
273 convert::to<u_int8_t> ( values, attribute_info.p_int_format ) );
274 }
275
276 break;
277 }
278
280 {
281 if ( attribute_info.p_is_multi_value )
282 {
284 Object, attribute_info,
285 convert::to<std::vector<u_int16_t>> ( values, attribute_info.p_int_format ) );
286 }
287 else
288 {
290 Object, attribute_info,
291 convert::to<u_int16_t> ( values, attribute_info.p_int_format ) );
292 }
293
294 break;
295 }
296
298 {
299 if ( attribute_info.p_is_multi_value )
300 {
302 Object, attribute_info,
303 convert::to<std::vector<u_int32_t>> ( values, attribute_info.p_int_format ) );
304 }
305 else
306 {
308 Object, attribute_info,
309 convert::to<u_int32_t> ( values, attribute_info.p_int_format ) );
310 }
311
312 break;
313 }
314
316 {
317 if ( attribute_info.p_is_multi_value ) commands::modobj (
318 Object, attribute_info,
319 convert::to<std::vector<u_int64_t>> ( values, attribute_info.p_int_format ) );
320 else commands::modobj (
321 Object, attribute_info,
322 convert::to<u_int64_t> ( values, attribute_info.p_int_format ) );
323
324 break;
325 }
326
327 default:
328 break;
329 }
330}
331//------------------------------------------------------------------------------------------
332}
333}
334}
335}
336//------------------------------------------------------------------------------------------
337
#define ERS_HERE
void set_objs(std::string const &name, std::vector< T > const &others, bool skip_non_null_check=false)
void set_obj_null(std::string const &name, bool is_simple, bool skip_non_null_check=false)
void set_obj(std::string const &name, T const &other, bool skip_non_null_check=false)
static configobject::tref get(dbe::cokey const &desc)
void modobj(tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T Value)
bool is_simple(dunedaq::conffwk::relationship_t const &)
void relation(dbe::inner::configobject::tref src, dunedaq::conffwk::relationship_t const &edge, std::vector< dbe::inner::configobject::tref > const &targets)
void relation(dbe::inner::configobject::tref src, dunedaq::conffwk::relationship_t const &edge, QStringList const &targets)
void attribute(dbe::inner::configobject::tref objectref, dunedaq::conffwk::attribute_t const &attribute_info, QStringList const &attribute_values)
std::string const parse(ers::Issue const &)
T to(QStringList const &DataList)
Include QT Headers.
inner::configobject::tref tref
Definition tref.hpp:35
config_object_key cokey