DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
config_api.hpp
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: yes (from dbe/config_api.hpp to include/dbe/config_api.hpp).
5
6
/*
7
* config_api.hpp
8
*
9
* Created on: Nov 9, 2015
10
* Author: lgeorgop
11
*/
12
13
#ifndef DBE_CONFIG_API_HPP_
14
#define DBE_CONFIG_API_HPP_
15
16
#include "
dbe/config_api_set.hpp
"
17
#include "
dbe/config_api_get.hpp
"
18
#include "
dbe/config_api_info.hpp
"
19
#include "
dbe/dbaccessor.hpp
"
20
#include "
dbe/confaccessor.hpp
"
21
#include "
dbe/change_attribute.hpp
"
22
#include "
dbe/messenger.hpp
"
23
24
#include <algorithm>
25
26
extern
char
const
*
const
dbe_lib_config_api_version
;
27
28
namespace
dbe
29
{
30
namespace
config
31
{
32
namespace
api
33
{
34
namespace
info
35
{
36
37
template
<
typename
T>
inline
T
onclass::allnames
()
38
{
39
typedef
dunedaq::conffwk::fmap<dunedaq::conffwk::fset>
type_cmap;
40
type_cmap
const
& baseclasses =
dbaccessor::dbptr
()->superclasses();
41
42
T config_class_list;
43
44
std::transform ( baseclasses.begin(), baseclasses.end(),
45
std::back_inserter ( config_class_list ),
46
[] ( type_cmap::value_type
const
& element )
47
{
48
return element.first->c_str();
49
} );
50
51
if
( not config_class_list.empty() )
52
{
53
std::sort ( std::begin ( config_class_list ), std::end ( config_class_list ) );
54
}
55
56
return
config_class_list;
57
}
58
}
59
//------------------------------------------------------------------------------------------
60
61
//------------------------------------------------------------------------------------------
62
namespace
get
63
{
64
template
<
typename
T>
inline
std::vector<std::string>
attribute::read
(
65
inner::configobject::tref
obj,
dunedaq::conffwk::attribute_t
const
& attr )
66
{
67
68
if
( attr.
p_is_multi_value
)
69
{
70
std::vector<T> values;
71
obj.get ( attr.
p_name
, values );
72
73
std::vector<std::string> result;
74
75
if
( attr.
p_int_format
==
dunedaq::conffwk::int_format_t::na_int_format
)
76
{
77
result.assign(values.size(),
""
);
78
std::transform ( values.begin(), values.end(), result.begin(),
79
( std::string ( * ) ( T
const
& ) )
convert::valtostr<T>
);
80
}
81
else
82
{
83
for
( T i : values )
84
{
85
result.push_back (
convert::valtostr
( i, attr.
p_int_format
) );
86
}
87
}
88
89
return
result;
90
}
91
else
92
{
93
T value;
94
obj.get ( attr.
p_name
, value );
95
96
if
( attr.
p_int_format
==
dunedaq::conffwk::int_format_t::na_int_format
)
97
{
98
return
99
{
convert::valtostr
( value ) };
100
}
101
else
102
{
103
return
104
{
convert::valtostr
( value, attr.
p_int_format
) };
105
}
106
}
107
}
108
}
109
//------------------------------------------------------------------------------------------
110
111
//------------------------------------------------------------------------------------------
112
namespace
commands
113
{
114
template
<
class
T>
115
void
modobj
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData, T Value )
116
{
117
try
118
{
119
std::string
const
description = std::string (
"Attribute "
) + AttributeData.
p_name
;
120
121
dbe::config_internal_change
Change
122
{
123
dbe::config_internal_change::MODIFIED
,
124
description,
125
Object.
UID
(),
126
Object.
class_name
(),
127
Object.
contained_in
() };
128
129
confaccessor::get_commands
()->push (
130
new
dbe::actions::ChangeAttribute<T>
( Object, AttributeData, Value ) );
131
confaccessor::get_internal_change_stack
()->push ( Change );
132
133
}
134
catch
( daq::dbe::ObjectChangeWasNotSuccessful
const
& dbe_err )
135
{
136
WARN
(
"The object attribute could not be changed"
,
dbe::config::errors::parse
( dbe_err ).c_str() );
137
}
138
catch
( dunedaq::conffwk::Exception
const
& e )
139
{
140
WARN
(
"Change Attribute: The attribute could not be changed"
,
141
dbe::config::errors::parse
( e ).c_str() );
142
}
143
}
144
//------------------------------------------------------------------------------------------
145
146
//------------------------------------------------------------------------------------------
147
template
<>
148
void
modobj<std::vector<std::string>
> (
tref
Object,
149
dunedaq::conffwk::attribute_t
const
& AttributeData,
150
std::vector<std::string> Value );
151
}
152
//------------------------------------------------------------------------------------------
153
154
//------------------------------------------------------------------------------------------
155
template
<
class
T>
156
void
set::noactions::attribute
(
tref
Object,
157
dunedaq::conffwk::attribute_t
const
& AttributeData,
158
T NewValueData,
159
bool
NotEmit )
160
{
161
if
( not
confaccessor::enabled
() )
162
{
163
throw
daq::dbe::ChangeNotAllowed (
ERS_HERE
);
164
}
165
166
try
167
{
168
Object.
set_by_ref
( AttributeData.
p_name
, NewValueData );
169
170
if
( !NotEmit )
171
{
172
confaccessor::ref
().
force_emit_object_changed
(
""
, Object );
173
}
174
}
175
catch
( dunedaq::conffwk::Exception
const
&
error
)
176
{
177
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
,
error
);
178
}
179
}
180
//------------------------------------------------------------------------------------------
181
182
//------------------------------------------------------------------------------------------
183
template
<
typename
T>
184
void
set::noactions::anenum
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData,
185
T NewValueData,
186
bool
NotEmit )
187
{
188
if
( not
confaccessor::enabled
() )
189
{
190
throw
daq::dbe::ChangeNotAllowed (
ERS_HERE
);
191
}
192
193
try
194
{
195
Object.
set_enum
( AttributeData.
p_name
, NewValueData );
196
197
if
( !NotEmit )
198
{
199
confaccessor::ref
().
force_emit_object_changed
(
""
, Object );
200
}
201
}
202
catch
( dunedaq::conffwk::Exception
const
&
error
)
203
{
204
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
,
error
);
205
}
206
}
207
//------------------------------------------------------------------------------------------
208
209
//------------------------------------------------------------------------------------------
210
template
<
typename
T>
211
void
set::noactions::aclass
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData,
212
T NewValueData,
213
bool
NotEmit )
214
{
215
if
( not
confaccessor::enabled
() )
216
{
217
throw
daq::dbe::ChangeNotAllowed (
ERS_HERE
);
218
}
219
220
try
221
{
222
Object.
set_class
( AttributeData.
p_name
, NewValueData );
223
224
if
( !NotEmit )
225
{
226
confaccessor::ref
().
force_emit_object_changed
(
""
, Object );
227
}
228
}
229
catch
( dunedaq::conffwk::Exception
const
&
error
)
230
{
231
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
,
error
);
232
}
233
}
234
//------------------------------------------------------------------------------------------
235
236
//------------------------------------------------------------------------------------------
237
template
<
typename
T>
238
void
set::noactions::adate
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData,
239
T NewValueData,
240
bool
NotEmit )
241
{
242
if
( not
confaccessor::enabled
() )
243
{
244
throw
daq::dbe::ChangeNotAllowed (
ERS_HERE
);
245
}
246
247
try
248
{
249
Object.
set_date
( AttributeData.
p_name
, NewValueData );
250
251
if
( !NotEmit )
252
{
253
confaccessor::ref
().
force_emit_object_changed
(
""
, Object );
254
}
255
256
}
257
catch
( dunedaq::conffwk::Exception
const
&
error
)
258
{
259
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
,
error
);
260
}
261
}
262
//------------------------------------------------------------------------------------------
263
264
//------------------------------------------------------------------------------------------
265
template
<
typename
T>
266
void
set::noactions::atime
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData,
267
T NewValueData,
268
bool
NotEmit )
269
{
270
if
( not
confaccessor::enabled
() )
271
{
272
throw
daq::dbe::ChangeNotAllowed (
ERS_HERE
);
273
}
274
275
try
276
{
277
Object.
set_time
( AttributeData.
p_name
, NewValueData );
278
279
if
( !NotEmit )
280
{
281
confaccessor::ref
().
force_emit_object_changed
(
""
, Object );
282
}
283
}
284
catch
( dunedaq::conffwk::Exception
const
&
error
)
285
{
286
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
,
error
);
287
}
288
}
289
290
}
291
/* namespace api */
292
}
/* namespace config */
293
}
/* namespace dbe */
294
295
#endif
/* DBE_CONFIG_API_HPP_ */
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
change_attribute.hpp
dbe::actions::ChangeAttribute
Definition
change_attribute.hpp:42
dbe::confaccessor::get_commands
static t_undo_stack_cptr get_commands()
Definition
confaccessor.cpp:150
dbe::confaccessor::enabled
static bool enabled()
Definition
confaccessor.cpp:69
dbe::confaccessor::force_emit_object_changed
void force_emit_object_changed(QString const &, dref const)
Definition
confaccessor.cpp:108
dbe::confaccessor::get_internal_change_stack
static t_internal_changes_stack_cptr get_internal_change_stack()
Definition
confaccessor.cpp:457
dbe::confaccessor::ref
static confaccessor & ref()
Definition
confaccessor.cpp:36
dbe::config::api::get::attribute::read
static std::vector< std::string > read(dunedaq::conffwk::ConfigObject &, dunedaq::conffwk::attribute_t const &)
Definition
config_api_get.cpp:40
dbe::config::api::info::onclass::allnames
static T allnames()
Definition
config_api.hpp:37
dbe::dbaccessor::dbptr
static cptr< dunedaq::conffwk::Configuration > dbptr()
Definition
dbaccessor.cpp:23
dbe::inner::configobject::ref_interface::set_enum
void set_enum(std::string const &name, std::string const &val)
Definition
config_reference.hpp:292
dbe::inner::configobject::ref_interface::set_by_ref
void set_by_ref(std::string const &name, U &val)
Definition
config_reference.hpp:287
dbe::inner::configobject::ref_interface::set_class
void set_class(std::string const &name, std::string const &val)
Definition
config_reference.hpp:297
dbe::inner::configobject::ref_interface::class_name
std::string class_name() const
Definition
config_reference.hpp:201
dbe::inner::configobject::ref_interface::set_date
void set_date(std::string const &name, std::string const &val)
Definition
config_reference.hpp:302
dbe::inner::configobject::ref_interface::UID
std::string UID() const
Definition
config_reference.hpp:196
dbe::inner::configobject::ref_interface::set_time
void set_time(std::string const &name, std::string const &val)
Definition
config_reference.hpp:307
dbe::inner::configobject::ref_interface::contained_in
std::string contained_in() const
Definition
config_reference.hpp:211
dbe::inner::configobject::tref
Definition
config_reference.hpp:457
dunedaq::conffwk::fmap
Definition
map.hpp:51
confaccessor.hpp
dbe_lib_config_api_version
char const *const dbe_lib_config_api_version
Definition
config_api.cpp:23
config_api_get.hpp
config_api_info.hpp
config_api_set.hpp
dbaccessor.hpp
messenger.hpp
WARN
#define WARN(...)
Definition
messenger.hpp:85
dbe::config::api::commands
Definition
config_api.hpp:113
dbe::config::api::commands::modobj
void modobj(tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T Value)
Definition
config_api.hpp:115
dbe::config::api::get
Definition
config_api.hpp:63
dbe::config::api::info
Definition
config_api.hpp:35
dbe::config::api::set::noactions::adate
void adate(inner::configobject::tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T NewValueData, bool NotEmit=false)
Definition
config_api.hpp:238
dbe::config::api::set::noactions::aclass
void aclass(inner::configobject::tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T NewValueData, bool NotEmit=false)
Definition
config_api.hpp:211
dbe::config::api::set::noactions::anenum
void anenum(inner::configobject::tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T NewValueData, bool NotEmit=false)
Definition
config_api.hpp:184
dbe::config::api::set::noactions::atime
void atime(inner::configobject::tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T NewValueData, bool NotEmit=false)
Definition
config_api.hpp:266
dbe::config::api::set::noactions::attribute
void attribute(inner::configobject::tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T NewValueData, bool NotEmit=false)
Definition
config_api.hpp:156
dbe::config::api
Definition
config_api.hpp:33
dbe::config::errors::parse
std::string const parse(ers::Issue const &)
Definition
config_api.cpp:113
dbe::config
Definition
config_api.hpp:31
dbe::convert::valtostr
std::string valtostr(T const &value)
Definition
Conversion.hpp:33
dbe
Include QT Headers.
Definition
BatchChangeWidget.hpp:18
dbe::tref
inner::configobject::tref tref
Definition
tref.hpp:35
dunedaq::conffwk::na_int_format
@ na_int_format
Definition
Schema.hpp:53
dbe::config_internal_change
Definition
confaccessor.hpp:29
dbe::config_internal_change::MODIFIED
@ MODIFIED
Definition
confaccessor.hpp:34
dunedaq::conffwk::attribute_t
Definition
Schema.hpp:59
dunedaq::conffwk::attribute_t::p_int_format
int_format_t p_int_format
Definition
Schema.hpp:64
dunedaq::conffwk::attribute_t::p_is_multi_value
bool p_is_multi_value
Definition
Schema.hpp:66
dunedaq::conffwk::attribute_t::p_name
std::string p_name
Definition
Schema.hpp:61
error
Factory couldn t std::string alg_name Invalid configuration error
Definition
Issues.hpp:34
Generated on
for DUNE-DAQ by
1.17.0