DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
change_attribute.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/change_attribute.hpp to include/dbe/change_attribute.hpp).
5
6
/*
7
* change_attribute.hpp
8
*
9
* Created on: Nov 10, 2015
10
* Author: lgeorgop
11
*/
12
13
#ifndef DBE_CHANGE_ATTRIBUTE_HPP_
14
#define DBE_CHANGE_ATTRIBUTE_HPP_
15
16
#include "
dbe/Command.hpp
"
17
#include "
dbe/Exceptions.hpp
"
18
#include "
dbe/confaccessor.hpp
"
19
#include "
dbe/config_api_get.hpp
"
20
#include "
dbe/config_api_set.hpp
"
21
22
#include "
conffwk/ConfigObject.hpp
"
23
#include "
conffwk/Errors.hpp
"
24
#include "
conffwk/Schema.hpp
"
25
26
#include <QtCore/qobject.h>
27
#include <QtCore/qstring.h>
28
#include <QtCore/qstringlist.h>
29
30
#include <string>
31
32
#include "
dbe/messenger.hpp
"
33
34
namespace
dbe
{
35
namespace
actions
{
36
37
template
<
typename
T>
38
class
ChangeAttribute
:
public
onobject
39
{
40
public
:
41
ChangeAttribute
(
tref
Object,
42
dunedaq::conffwk::attribute_t
AttributeData,
43
T NewValueData,
44
QUndoCommand* parent =
nullptr
);
45
void
undo
();
46
void
redo
();
47
48
private
:
49
T
OldValue
;
50
T
NewValue
;
51
dunedaq::conffwk::attribute_t
Attribute
;
52
};
53
54
template
<
typename
T>
55
ChangeAttribute<T>::ChangeAttribute
(
tref
Object,
56
dunedaq::conffwk::attribute_t
AttributeData,
57
T NewValueData,
58
QUndoCommand* parent)
59
:
onobject
(Object, parent)
60
,
NewValue
(NewValueData)
61
,
Attribute
(AttributeData)
62
{
63
try
{
64
failed
();
65
QStringList Data{
dbe::config::api::get::attribute::list<QStringList>
(this->
checkedref
(),
Attribute
) };
66
OldValue
=
convert::to<T>
(Data,
Attribute
.
p_int_format
);
67
toggle
();
68
}
catch
(dunedaq::conffwk::Exception
const
&) {
69
}
catch
(daq::dbe::config_object_retrieval_result_is_null
const
& ex) {
70
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
, ex.what());
71
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, ex);
72
}
73
74
setText(
75
QObject::tr(
"Attribute %1 of object %2 was updated."
).arg(AttributeData.
p_name
.c_str()).arg(Object.
UID
().c_str()));
76
}
77
78
template
<
typename
T>
79
void
80
ChangeAttribute<T>::undo
()
81
{
82
try
{
83
if
(
undoable
()) {
84
failed
();
85
dbe::config::api::set::noactions::attribute
(this->
checkedref
(),
Attribute
,
OldValue
);
86
toggle
();
87
}
88
}
catch
(dunedaq::conffwk::Exception
const
& e) {
89
failed
();
90
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, e);
91
}
catch
(daq::dbe::config_object_retrieval_result_is_null
const
& ex) {
92
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
, ex.what());
93
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, ex);
94
}
95
}
96
97
template
<
typename
T>
98
void
99
ChangeAttribute<T>::redo
()
100
{
101
try
{
102
if
(
redoable
()) {
103
failed
();
104
105
QStringList Data{
dbe::config::api::get::attribute::list<QStringList>
(this->
checkedref
(),
Attribute
) };
106
107
OldValue
=
convert::to<T>
(Data,
Attribute
.p_int_format);
108
109
dbe::config::api::set::noactions::attribute
(this->
checkedref
(),
Attribute
,
NewValue
);
110
toggle
();
111
}
112
}
catch
(dunedaq::conffwk::Exception
const
& e) {
113
failed
();
114
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, e);
115
}
catch
(daq::dbe::config_object_retrieval_result_is_null
const
& ex) {
116
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
, ex.what());
117
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, ex);
118
}
119
}
120
121
}
122
}
123
#endif
/* DBE_CHANGE_ATTRIBUTE_HPP_ */
Command.hpp
ConfigObject.hpp
Errors.hpp
Exceptions.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:127
dbe::actions::ChangeAttribute::OldValue
T OldValue
Definition
change_attribute.hpp:49
dbe::actions::ChangeAttribute::ChangeAttribute
ChangeAttribute(tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData, QUndoCommand *parent=nullptr)
Definition
change_attribute.hpp:55
dbe::actions::ChangeAttribute::undo
void undo()
Definition
change_attribute.hpp:80
dbe::actions::ChangeAttribute::redo
void redo()
Definition
change_attribute.hpp:99
dbe::actions::ChangeAttribute::NewValue
T NewValue
Definition
change_attribute.hpp:50
dbe::actions::ChangeAttribute::Attribute
dunedaq::conffwk::attribute_t Attribute
Definition
change_attribute.hpp:51
dbe::actions::onobject::checkedref
tref checkedref() const
Definition
Command.cpp:412
dbe::actions::onobject::onobject
onobject(tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Definition
Command.cpp:403
dbe::actions::state::toggle
void toggle()
Definition
Command.cpp:429
dbe::actions::state::undoable
bool undoable() const
Definition
Command.cpp:463
dbe::actions::state::failed
void failed() const
Definition
Command.cpp:437
dbe::actions::state::redoable
bool redoable() const
Definition
Command.cpp:469
dbe::config::api::get::attribute::list
static T list(dbe::inner::configobject::tref obj, dunedaq::conffwk::attribute_t const &attr)
Definition
config_api_get.cpp:160
dbe::inner::configobject::ref_interface::UID
std::string UID() const
Definition
config_reference.hpp:178
confaccessor.hpp
Schema.hpp
config_api_get.hpp
config_api_set.hpp
messenger.hpp
FAIL
#define FAIL(...)
Definition
messenger.hpp:129
dbe::actions
Definition
change_attribute.hpp:35
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::convert::to
T to(QStringList const &DataList)
Definition
Conversion.hpp:114
dbe
Include QT Headers.
Definition
BatchChangeWidget.hpp:16
dbe::tref
inner::configobject::tref tref
Definition
tref.hpp:36
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_name
std::string p_name
Definition
Schema.hpp:62
Generated on
for DUNE-DAQ by
1.18.0