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
14#include "dbe/Conversion.hpp"
15#include "dbe/config_api.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//------------------------------------------------------------------------------------------
33namespace dbe {
34namespace config {
35namespace api {
36namespace set {
37namespace noactions {
38
39void
40relation(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
51void
52relation(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 {
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//------------------------------------------------------------------------------------------
79namespace dbe {
80namespace config {
81namespace api {
82namespace set {
83
84//------------------------------------------------------------------------------------------
85void
86relation(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//------------------------------------------------------------------------------------------
99void
100attribute(tref Object, dunedaq::conffwk::attribute_t const& attribute_info, QStringList const& values)
101{
102 switch (attribute_info.p_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
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
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
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
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
158 if (attribute_info.p_is_multi_value) {
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
169 if (attribute_info.p_is_multi_value) {
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
180 if (attribute_info.p_is_multi_value) {
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
191 if (attribute_info.p_is_multi_value) {
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
202 if (attribute_info.p_is_multi_value) {
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
213 if (attribute_info.p_is_multi_value) {
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
224 if (attribute_info.p_is_multi_value)
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//------------------------------------------------------------------------------------------
#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:36
config_object_key cokey