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