DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
change_enum.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_enum.hpp to include/dbe/change_enum.hpp).
5
6
/*
7
* change_enum.hpp
8
*
9
* Created on: Nov 10, 2015
10
* Author: lgeorgop
11
*/
12
13
#ifndef DBE_CHANGE_ENUM_HPP_
14
#define DBE_CHANGE_ENUM_HPP_
15
16
#include "
dbe/confaccessor.hpp
"
17
#include "
dbe/config_api_get.hpp
"
18
#include "
dbe/config_api_set.hpp
"
19
#include "
dbe/Command.hpp
"
20
#include "
dbe/Exceptions.hpp
"
21
#include "
dbe/messenger.hpp
"
22
23
#include "
conffwk/ConfigObject.hpp
"
24
#include "
conffwk/Errors.hpp
"
25
#include "
conffwk/Schema.hpp
"
26
27
#include <QtCore/qobject.h>
28
#include <QtCore/qstring.h>
29
#include <QtCore/qstringlist.h>
30
31
#include <string>
32
33
namespace
dbe
34
{
35
namespace
actions
36
{
37
//------------------------------------------------------------------------------------------
38
template
<
typename
T>
39
class
ChangeEnum
:
40
public
onobject
41
{
42
public
:
43
ChangeEnum
(
tref
Object,
dunedaq::conffwk::attribute_t
AttributeData, 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
bool
Success
;
53
};
54
55
template
<
typename
T>
56
ChangeEnum<T>::ChangeEnum
(
tref
Object,
dunedaq::conffwk::attribute_t
AttributeData,
57
T NewValueData, QUndoCommand * parent )
58
:
onobject
( Object, parent ),
59
NewValue
( NewValueData ),
60
Attribute
( AttributeData ),
61
Success
( true )
62
{
63
try
64
{
65
QStringList Data
66
{
dbe::config::api::get::attribute::list<QStringList>
( Object,
Attribute
) };
67
OldValue
=
convert::to<T>
( Data );
68
}
69
catch
( dunedaq::conffwk::Exception
const
& e )
70
{
71
Q_UNUSED ( e )
72
}
73
74
setText (
75
QObject::tr (
"Attribute %1 of object %2 was updated."
).arg (
76
AttributeData.
p_name
.c_str() ).arg ( Object.
UID
().c_str() ) );
77
}
78
79
template
<
typename
T>
80
void
ChangeEnum<T>::undo
()
81
{
82
try
83
{
84
if
(
isvalid
() )
85
{
86
failed
();
87
dbe::config::api::set::noactions::anenum
( this->
checkedref
(),
Attribute
,
OldValue
);
88
toggle
();
89
}
90
}
91
catch
( dunedaq::conffwk::Exception
const
& e )
92
{
93
Success
=
false
;
94
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, e );
95
}
96
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
97
{
98
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
,
99
ex.what() );
100
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, ex );
101
}
102
103
}
104
105
template
<
typename
T>
106
void
ChangeEnum<T>::redo
()
107
{
108
try
109
{
110
if
(
isvalid
() )
111
{
112
failed
();
113
114
QStringList Data
115
{
dbe::config::api::get::attribute::list<QStringList>
( this->
checkedref
(),
Attribute
) };
116
117
OldValue
=
convert::to<T>
( Data,
Attribute
.p_int_format );
118
119
dbe::config::api::set::noactions::anenum
( this->
checkedref
(),
Attribute
,
NewValue
);
120
121
toggle
();
122
}
123
}
124
catch
( dunedaq::conffwk::Exception
const
& e )
125
{
126
Success
=
false
;
127
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, e );
128
}
129
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
130
{
131
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
,
132
ex.what() );
133
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, ex );
134
}
135
136
}
137
//------------------------------------------------------------------------------------------
138
}
139
}
// namespace dbe
140
#endif
/* DBE_CHANGE_ENUM_HPP_ */
Command.hpp
ConfigObject.hpp
Errors.hpp
Exceptions.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
dbe::actions::ChangeEnum::undo
void undo()
Definition
change_enum.hpp:80
dbe::actions::ChangeEnum::OldValue
T OldValue
Definition
change_enum.hpp:49
dbe::actions::ChangeEnum::redo
void redo()
Definition
change_enum.hpp:106
dbe::actions::ChangeEnum::NewValue
T NewValue
Definition
change_enum.hpp:50
dbe::actions::ChangeEnum::Success
bool Success
Definition
change_enum.hpp:52
dbe::actions::ChangeEnum::Attribute
dunedaq::conffwk::attribute_t Attribute
Definition
change_enum.hpp:51
dbe::actions::ChangeEnum::ChangeEnum
ChangeEnum(tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData, QUndoCommand *parent=nullptr)
Definition
change_enum.hpp:56
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::isvalid
bool isvalid() const
Definition
Command.cpp:548
dbe::actions::state::failed
void failed() const
Definition
Command.cpp:541
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::anenum
void anenum(inner::configobject::tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T NewValueData, bool NotEmit=false)
Definition
config_api.hpp:184
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