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/change_attribute.hpp
"
17
#include "
dbe/confaccessor.hpp
"
18
#include "
dbe/config_api_get.hpp
"
19
#include "
dbe/config_api_info.hpp
"
20
#include "
dbe/config_api_set.hpp
"
21
#include "
dbe/dbaccessor.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
namespace
config
{
30
namespace
api
{
31
namespace
info
{
32
33
template
<
typename
T>
34
inline
T
35
onclass::allnames
()
36
{
37
typedef
dunedaq::conffwk::fmap<dunedaq::conffwk::fset>
type_cmap;
38
type_cmap
const
& baseclasses =
dbaccessor::dbptr
()->superclasses();
39
40
T config_class_list;
41
42
std::transform(baseclasses.begin(),
43
baseclasses.end(),
44
std::back_inserter(config_class_list),
45
[](type_cmap::value_type
const
& element) { return element.first->c_str(); });
46
47
if
(not config_class_list.empty()) {
48
std::sort(std::begin(config_class_list), std::end(config_class_list));
49
}
50
51
return
config_class_list;
52
}
53
}
54
//------------------------------------------------------------------------------------------
55
56
//------------------------------------------------------------------------------------------
57
namespace
get
{
58
template
<
typename
T>
59
inline
std::vector<std::string>
60
attribute::read
(
inner::configobject::tref
obj,
dunedaq::conffwk::attribute_t
const
& attr)
61
{
62
63
if
(attr.
p_is_multi_value
) {
64
std::vector<T> values;
65
obj.get(attr.
p_name
, values);
66
67
std::vector<std::string> result;
68
69
if
(attr.
p_int_format
==
dunedaq::conffwk::int_format_t::na_int_format
) {
70
result.assign(values.size(),
""
);
71
std::transform(values.begin(), values.end(), result.begin(), (std::string(*)(T
const
&))
convert::valtostr<T>
);
72
}
else
{
73
for
(T i : values) {
74
result.push_back(
convert::valtostr
(i, attr.
p_int_format
));
75
}
76
}
77
78
return
result;
79
}
else
{
80
T value;
81
obj.get(attr.
p_name
, value);
82
83
if
(attr.
p_int_format
==
dunedaq::conffwk::int_format_t::na_int_format
) {
84
return
{
convert::valtostr
(value) };
85
}
else
{
86
return
{
convert::valtostr
(value, attr.
p_int_format
) };
87
}
88
}
89
}
90
}
91
//------------------------------------------------------------------------------------------
92
93
//------------------------------------------------------------------------------------------
94
namespace
commands
{
95
template
<
class
T>
96
void
97
modobj
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData, T Value)
98
{
99
try
{
100
std::string
const
description = std::string(
"Attribute "
) + AttributeData.
p_name
;
101
102
dbe::config_internal_change
Change{
103
dbe::config_internal_change::MODIFIED
, description, Object.
UID
(), Object.
class_name
(), Object.
contained_in
()
104
};
105
106
confaccessor::get_commands
()->push(
new
dbe::actions::ChangeAttribute<T>
(Object, AttributeData, Value));
107
confaccessor::get_internal_change_stack
()->push(Change);
108
109
}
catch
(daq::dbe::ObjectChangeWasNotSuccessful
const
& dbe_err) {
110
WARN
(
"The object attribute could not be changed"
,
dbe::config::errors::parse
(dbe_err).c_str());
111
}
catch
(dunedaq::conffwk::Exception
const
& e) {
112
WARN
(
"Change Attribute: The attribute could not be changed"
,
dbe::config::errors::parse
(e).c_str());
113
}
114
}
115
//------------------------------------------------------------------------------------------
116
117
//------------------------------------------------------------------------------------------
118
template
<>
119
void
120
modobj<std::vector<std::string>
>(
tref
Object,
121
dunedaq::conffwk::attribute_t
const
& AttributeData,
122
std::vector<std::string> Value);
123
}
124
//------------------------------------------------------------------------------------------
125
126
//------------------------------------------------------------------------------------------
127
template
<
class
T>
128
void
129
set::noactions::attribute
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData, T NewValueData,
bool
NotEmit)
130
{
131
if
(not
confaccessor::enabled
()) {
132
throw
daq::dbe::ChangeNotAllowed(
ERS_HERE
);
133
}
134
135
try
{
136
Object.
set_by_ref
(AttributeData.
p_name
, NewValueData);
137
138
if
(!NotEmit) {
139
confaccessor::ref
().
force_emit_object_changed
(
""
, Object);
140
}
141
}
catch
(dunedaq::conffwk::Exception
const
&
error
) {
142
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
,
error
);
143
}
144
}
145
//------------------------------------------------------------------------------------------
146
147
//------------------------------------------------------------------------------------------
148
template
<
typename
T>
149
void
150
set::noactions::anenum
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData, T NewValueData,
bool
NotEmit)
151
{
152
if
(not
confaccessor::enabled
()) {
153
throw
daq::dbe::ChangeNotAllowed(
ERS_HERE
);
154
}
155
156
try
{
157
Object.
set_enum
(AttributeData.
p_name
, NewValueData);
158
159
if
(!NotEmit) {
160
confaccessor::ref
().
force_emit_object_changed
(
""
, Object);
161
}
162
}
catch
(dunedaq::conffwk::Exception
const
&
error
) {
163
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
,
error
);
164
}
165
}
166
//------------------------------------------------------------------------------------------
167
168
//------------------------------------------------------------------------------------------
169
template
<
typename
T>
170
void
171
set::noactions::aclass
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData, T NewValueData,
bool
NotEmit)
172
{
173
if
(not
confaccessor::enabled
()) {
174
throw
daq::dbe::ChangeNotAllowed(
ERS_HERE
);
175
}
176
177
try
{
178
Object.
set_class
(AttributeData.
p_name
, NewValueData);
179
180
if
(!NotEmit) {
181
confaccessor::ref
().
force_emit_object_changed
(
""
, Object);
182
}
183
}
catch
(dunedaq::conffwk::Exception
const
&
error
) {
184
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
,
error
);
185
}
186
}
187
//------------------------------------------------------------------------------------------
188
189
//------------------------------------------------------------------------------------------
190
template
<
typename
T>
191
void
192
set::noactions::adate
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData, T NewValueData,
bool
NotEmit)
193
{
194
if
(not
confaccessor::enabled
()) {
195
throw
daq::dbe::ChangeNotAllowed(
ERS_HERE
);
196
}
197
198
try
{
199
Object.
set_date
(AttributeData.
p_name
, NewValueData);
200
201
if
(!NotEmit) {
202
confaccessor::ref
().
force_emit_object_changed
(
""
, Object);
203
}
204
205
}
catch
(dunedaq::conffwk::Exception
const
&
error
) {
206
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
,
error
);
207
}
208
}
209
//------------------------------------------------------------------------------------------
210
211
//------------------------------------------------------------------------------------------
212
template
<
typename
T>
213
void
214
set::noactions::atime
(
tref
Object,
dunedaq::conffwk::attribute_t
const
& AttributeData, T NewValueData,
bool
NotEmit)
215
{
216
if
(not
confaccessor::enabled
()) {
217
throw
daq::dbe::ChangeNotAllowed(
ERS_HERE
);
218
}
219
220
try
{
221
Object.
set_time
(AttributeData.
p_name
, NewValueData);
222
223
if
(!NotEmit) {
224
confaccessor::ref
().
force_emit_object_changed
(
""
, Object);
225
}
226
}
catch
(dunedaq::conffwk::Exception
const
&
error
) {
227
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
,
error
);
228
}
229
}
230
231
}
232
/* namespace api */
233
}
/* namespace config */
234
}
/* namespace dbe */
235
236
#endif
/* DBE_CONFIG_API_HPP_ */
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:127
change_attribute.hpp
dbe::actions::ChangeAttribute
Definition
change_attribute.hpp:39
dbe::confaccessor::get_commands
static t_undo_stack_cptr get_commands()
Definition
confaccessor.cpp:164
dbe::confaccessor::enabled
static bool enabled()
Definition
confaccessor.cpp:71
dbe::confaccessor::force_emit_object_changed
void force_emit_object_changed(QString const &, dref const)
Definition
confaccessor.cpp:116
dbe::confaccessor::get_internal_change_stack
static t_internal_changes_stack_cptr get_internal_change_stack()
Definition
confaccessor.cpp:463
dbe::confaccessor::ref
static confaccessor & ref()
Definition
confaccessor.cpp:37
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:36
dbe::config::api::info::onclass::allnames
static T allnames()
Definition
config_api.hpp:35
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:258
dbe::inner::configobject::ref_interface::set_by_ref
void set_by_ref(std::string const &name, U &val)
Definition
config_reference.hpp:253
dbe::inner::configobject::ref_interface::set_class
void set_class(std::string const &name, std::string const &val)
Definition
config_reference.hpp:263
dbe::inner::configobject::ref_interface::class_name
std::string class_name() const
Definition
config_reference.hpp:180
dbe::inner::configobject::ref_interface::set_date
void set_date(std::string const &name, std::string const &val)
Definition
config_reference.hpp:268
dbe::inner::configobject::ref_interface::UID
std::string UID() const
Definition
config_reference.hpp:178
dbe::inner::configobject::ref_interface::set_time
void set_time(std::string const &name, std::string const &val)
Definition
config_reference.hpp:273
dbe::inner::configobject::ref_interface::contained_in
std::string contained_in() const
Definition
config_reference.hpp:184
dbe::inner::configobject::tref
Definition
config_reference.hpp:416
dunedaq::conffwk::fmap
Definition
map.hpp:41
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:82
dbe::config::api::commands
Definition
config_api.hpp:94
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::get
Definition
config_api.hpp:57
dbe::config::api::info
Definition
config_api.hpp:31
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:192
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:171
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:150
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:214
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:129
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::valtostr
std::string valtostr(T const &value)
Definition
Conversion.hpp:33
dbe
Include QT Headers.
Definition
BatchChangeWidget.hpp:16
dbe::tref
inner::configobject::tref tref
Definition
tref.hpp:36
dunedaq::conffwk::na_int_format
@ na_int_format
Definition
Schema.hpp:54
dbe::config_internal_change
Definition
confaccessor.hpp:28
dbe::config_internal_change::MODIFIED
@ MODIFIED
Definition
confaccessor.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_name
std::string p_name
Definition
Schema.hpp:62
error
Factory couldn t std::string alg_name Invalid configuration error
Definition
Issues.hpp:34
Generated on
for DUNE-DAQ by
1.18.0