DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
config_api_set.cpp
Go to the documentation of this file.
1/*
2 * config_api_set.cpp
3 *
4 * Created on: Apr 19, 2016
5 * Author: Leonidas Georgopoulos
6 */
7
10#include "dbe/config_api.hpp"
13#include "dbe/Conversion.hpp"
14#include "dbe/dbcontroller.hpp"
15
16#include "conffwk/Schema.hpp"
17
18#include <QString>
19
20#include <stdint.h>
21#include <sys/types.h>
22#include <algorithm>
23#include <iterator>
24
25//------------------------------------------------------------------------------------------
26// NAMESPACE DBE::CONFIG::API::SET::NOACTIONS
27//------------------------------------------------------------------------------------------
28namespace dbe
29{
30namespace config
31{
32namespace api
33{
34namespace set
35{
36namespace noactions
37{
38
39void relation ( tref object, dunedaq::conffwk::relationship_t const & arelation,
40 std::vector<dbe::cokey> const & keys )
41{
42 std::vector<dbe::inner::configobject::tref> trefs;
43
44 for ( dbe::cokey const & key : keys )
45 {
46 trefs.push_back ( dbe::inner::dbcontroller::get ( key ) );
47 }
48
49 dbe::config::api::set::noactions::relation ( object, arelation, trefs );
50}
51
53 std::vector<tref> const & targets )
54{
55 try
56 {
57 if ( not targets.empty() )
58 {
59 if ( info::relation::is_simple ( edge ) )
60 {
61 src.set_obj ( edge.p_name, targets.back() );
62 }
63 else
64 {
65 src.set_objs ( edge.p_name, targets );
66 }
67 }
68 else
69 {
71 }
72 }
73 catch ( dunedaq::conffwk::Exception const & e )
74 {
75 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, config::errors::parse ( e ) );
76 }
77}
78//------------------------------------------------------------------------------------------
79}
80}
81}
82}
83}
84//------------------------------------------------------------------------------------------
85
86//------------------------------------------------------------------------------------------
87// NAMESPACE DBE::CONFIG::API::SET
88//------------------------------------------------------------------------------------------
89namespace dbe
90{
91namespace config
92{
93namespace api
94{
95namespace set
96{
97
98//------------------------------------------------------------------------------------------
100 QStringList const & targets )
101{
102 std::vector<std::string> targetnames;
103
104 for ( QString const & name : targets )
105 {
106 targetnames.push_back ( name.toStdString() );
107 }
108
109 commands::modobj ( src, edge, targetnames );
110}
111//------------------------------------------------------------------------------------------
112
113//------------------------------------------------------------------------------------------
114void attribute ( tref Object, dunedaq::conffwk::attribute_t const & attribute_info,
115 QStringList const & values )
116{
117 switch ( attribute_info.p_type )
118 {
120 {
121 if ( attribute_info.p_is_multi_value )
122 {
124 Object, attribute_info,
125 convert::to<std::vector<bool>> ( values, attribute_info.p_int_format ) );
126 }
127 else
128 {
129 commands::modobj ( Object, attribute_info,
130 convert::to<bool> ( values, attribute_info.p_int_format ) );
131 }
132
133 break;
134 }
135
141 {
142 if ( attribute_info.p_is_multi_value )
143 {
144 commands::modobj ( Object, attribute_info,
145 convert::to<std::vector<std::string>> ( values ) );
146 }
147 else
148 {
149 commands::modobj ( Object, attribute_info, convert::to<std::string> ( values ) );
150 }
151
152 break;
153 }
154
156 {
157 if ( attribute_info.p_is_multi_value )
158 {
160 Object, attribute_info,
161 convert::to<std::vector<float>> ( values, attribute_info.p_int_format ) );
162 }
163 else
164 {
165 commands::modobj ( Object, attribute_info,
166 convert::to<float> ( values, attribute_info.p_int_format ) );
167 }
168
169 break;
170 }
171
173 {
174 if ( attribute_info.p_is_multi_value )
175 {
177 Object, attribute_info,
178 convert::to<std::vector<double>> ( values, attribute_info.p_int_format ) );
179 }
180 else
181 {
182 commands::modobj ( Object, attribute_info,
183 convert::to<double> ( values, attribute_info.p_int_format ) );
184 }
185
186 break;
187 }
188
190 {
191 if ( attribute_info.p_is_multi_value )
192 {
194 Object, attribute_info,
195 convert::to<std::vector<int8_t>> ( values, attribute_info.p_int_format ) );
196 }
197 else
198 {
199 commands::modobj ( Object, attribute_info,
200 convert::to<int8_t> ( values, attribute_info.p_int_format ) );
201 }
202
203 break;
204 }
205
207 {
208 if ( attribute_info.p_is_multi_value )
209 {
211 Object, attribute_info,
212 convert::to<std::vector<int16_t>> ( values, attribute_info.p_int_format ) );
213 }
214 else
215 {
216 commands::modobj ( Object, attribute_info,
217 convert::to<int16_t> ( values, attribute_info.p_int_format ) );
218 }
219
220 break;
221 }
222
224 {
225 if ( attribute_info.p_is_multi_value )
226 {
228 Object, attribute_info,
229 convert::to<std::vector<int32_t>> ( values, attribute_info.p_int_format ) );
230 }
231 else
232 {
233 commands::modobj ( Object, attribute_info,
234 convert::to<int32_t> ( values, attribute_info.p_int_format ) );
235 }
236
237 break;
238 }
239
241 {
242 if ( attribute_info.p_is_multi_value )
243 {
245 Object, attribute_info,
246 convert::to<std::vector<int64_t>> ( values, attribute_info.p_int_format ) );
247 }
248 else
249 {
250 commands::modobj ( Object, attribute_info,
251 convert::to<int64_t> ( values, attribute_info.p_int_format ) );
252 }
253
254 break;
255 }
256
258 {
259 if ( attribute_info.p_is_multi_value )
260 {
262 Object, attribute_info,
263 convert::to<std::vector<u_int8_t>> ( values, attribute_info.p_int_format ) );
264 }
265 else
266 {
267 commands::modobj ( Object, attribute_info,
268 convert::to<u_int8_t> ( values, attribute_info.p_int_format ) );
269 }
270
271 break;
272 }
273
275 {
276 if ( attribute_info.p_is_multi_value )
277 {
279 Object, attribute_info,
280 convert::to<std::vector<u_int16_t>> ( values, attribute_info.p_int_format ) );
281 }
282 else
283 {
285 Object, attribute_info,
286 convert::to<u_int16_t> ( values, attribute_info.p_int_format ) );
287 }
288
289 break;
290 }
291
293 {
294 if ( attribute_info.p_is_multi_value )
295 {
297 Object, attribute_info,
298 convert::to<std::vector<u_int32_t>> ( values, attribute_info.p_int_format ) );
299 }
300 else
301 {
303 Object, attribute_info,
304 convert::to<u_int32_t> ( values, attribute_info.p_int_format ) );
305 }
306
307 break;
308 }
309
311 {
312 if ( attribute_info.p_is_multi_value ) commands::modobj (
313 Object, attribute_info,
314 convert::to<std::vector<u_int64_t>> ( values, attribute_info.p_int_format ) );
315 else commands::modobj (
316 Object, attribute_info,
317 convert::to<u_int64_t> ( values, attribute_info.p_int_format ) );
318
319 break;
320 }
321
322 default:
323 break;
324 }
325}
326//------------------------------------------------------------------------------------------
327}
328}
329}
330}
331//------------------------------------------------------------------------------------------
332
#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 &)
int8_t to< int8_t >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
u_int64_t to< u_int64_t >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
int16_t to< int16_t >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
u_int8_t to< u_int8_t >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
int64_t to< int64_t >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
T to(QStringList const &DataList)
std::string to< std::string >(QStringList const &DataList)
int32_t to< int32_t >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
u_int32_t to< u_int32_t >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
double to< double >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
u_int16_t to< u_int16_t >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
float to< float >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
bool to< bool >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
Include QT Headers.
std::unordered_set< std::string > set
Definition set.hpp:10