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/confaccessor.hpp
"
17
#include "
dbe/config_api_set.hpp
"
18
#include "
dbe/config_api_get.hpp
"
19
#include "
dbe/Command.hpp
"
20
#include "
dbe/Exceptions.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
{
36
namespace
actions
37
{
38
39
template
<
typename
T>
40
class
ChangeAttribute
:
41
public
onobject
42
{
43
public
:
44
ChangeAttribute
(
tref
Object,
dunedaq::conffwk::attribute_t
AttributeData, T NewValueData,
45
QUndoCommand * parent =
nullptr
);
46
void
undo
();
47
void
redo
();
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,
dunedaq::conffwk::attribute_t
AttributeData,
56
T NewValueData, QUndoCommand * parent )
57
:
onobject
( Object, parent ),
58
NewValue
( NewValueData ),
59
Attribute
( AttributeData )
60
{
61
try
62
{
63
failed
();
64
QStringList Data
65
{
dbe::config::api::get::attribute::list<QStringList>
( this->
checkedref
(),
Attribute
) };
66
OldValue
=
convert::to<T>
( Data,
Attribute
.p_int_format );
67
toggle
();
68
}
69
catch
( dunedaq::conffwk::Exception
const
& )
70
{
71
}
72
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
73
{
74
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
,
75
ex.what() );
76
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, ex );
77
}
78
79
setText (
80
QObject::tr (
"Attribute %1 of object %2 was updated."
).arg (
81
AttributeData.
p_name
.c_str() ).arg ( Object.
UID
().c_str() ) );
82
}
83
84
template
<
typename
T>
85
void
ChangeAttribute<T>::undo
()
86
{
87
try
88
{
89
if
(
undoable
() )
90
{
91
failed
();
92
dbe::config::api::set::noactions::attribute
( this->
checkedref
(),
Attribute
,
OldValue
);
93
toggle
();
94
}
95
}
96
catch
( dunedaq::conffwk::Exception
const
& e )
97
{
98
failed
();
99
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, e );
100
}
101
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
102
{
103
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
,
104
ex.what() );
105
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, ex );
106
}
107
108
}
109
110
template
<
typename
T>
111
void
ChangeAttribute<T>::redo
()
112
{
113
try
114
{
115
if
(
redoable
() )
116
{
117
failed
();
118
119
QStringList Data
120
{
dbe::config::api::get::attribute::list<QStringList>
( this->
checkedref
(),
Attribute
) };
121
122
OldValue
=
convert::to<T>
( Data,
Attribute
.p_int_format );
123
124
dbe::config::api::set::noactions::attribute
( this->
checkedref
(),
Attribute
,
NewValue
);
125
toggle
();
126
}
127
}
128
catch
( dunedaq::conffwk::Exception
const
& e )
129
{
130
failed
();
131
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, e );
132
}
133
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
134
{
135
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
,
136
ex.what() );
137
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, ex );
138
}
139
140
}
141
142
}
143
}
144
#endif
/* DBE_CHANGE_ATTRIBUTE_HPP_ */
Command.hpp
ConfigObject.hpp
Errors.hpp
Exceptions.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
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:85
dbe::actions::ChangeAttribute::redo
void redo()
Definition
change_attribute.hpp:111
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:518
dbe::actions::onobject::onobject
onobject(tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Definition
Command.cpp:510
dbe::actions::state::toggle
void toggle()
Definition
Command.cpp:534
dbe::actions::state::undoable
bool undoable() const
Definition
Command.cpp:563
dbe::actions::state::failed
void failed() const
Definition
Command.cpp:541
dbe::actions::state::redoable
bool redoable() const
Definition
Command.cpp:568
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:178
dbe::inner::configobject::ref_interface::UID
std::string UID() const
Definition
config_reference.hpp:196
confaccessor.hpp
Schema.hpp
config_api_get.hpp
config_api_set.hpp
messenger.hpp
FAIL
#define FAIL(...)
Definition
messenger.hpp:133
dbe::actions
Definition
change_attribute.hpp:37
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::convert::to
T to(QStringList const &DataList)
Definition
Conversion.hpp:116
dbe
Include QT Headers.
Definition
BatchChangeWidget.hpp:18
dbe::tref
inner::configobject::tref tref
Definition
tref.hpp:35
dunedaq::conffwk::attribute_t
Definition
Schema.hpp:59
dunedaq::conffwk::attribute_t::p_name
std::string p_name
Definition
Schema.hpp:61
Generated on
for DUNE-DAQ by
1.17.0