DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
change_date.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_date.hpp to include/dbe/change_date.hpp).
5
6
/*
7
* change_date.hpp
8
*
9
* Created on: Nov 10, 2015
10
* Author: lgeorgop
11
*/
12
13
#ifndef DBE_CHANGE_DATE_HPP_
14
#define DBE_CHANGE_DATE_HPP_
15
16
#include "
dbe/confaccessor.hpp
"
17
#include "
dbe/config_api_set.hpp
"
18
#include "
dbe/Command.hpp
"
19
#include "
dbe/Exceptions.hpp
"
20
#include "
dbe/messenger.hpp
"
21
22
#include "
conffwk/ConfigObject.hpp
"
23
#include "
conffwk/Errors.hpp
"
24
#include "
conffwk/Schema.hpp
"
25
26
#include <QObject>
27
#include <QString>
28
#include <string>
29
30
namespace
dbe
31
{
32
namespace
actions
33
{
34
35
//------------------------------------------------------------------------------------------
36
template
<
typename
T>
37
class
ChangeDate
:
38
public
onobject
39
{
40
public
:
41
ChangeDate
(
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
ChangeDate<T>::ChangeDate
(
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
ChangeDate<T>::undo
()
78
{
79
try
80
{
81
if
(
isvalid
() )
82
{
83
failed
();
84
dbe::config::api::set::noactions::adate
( 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
template
<
typename
T>
102
void
ChangeDate<T>::redo
()
103
{
104
try
105
{
106
if
(
isvalid
() )
107
{
108
failed
();
109
QStringList Data
110
{
dbe::config::api::get::attribute::list<QStringList>
( this->
checkedref
(),
Attribute
) };
111
OldValue
=
convert::to<T>
( Data );
112
113
dbe::config::api::set::noactions::adate
( this->
checkedref
(),
Attribute
,
NewValue
);
114
toggle
();
115
}
116
}
117
catch
( dunedaq::conffwk::Exception
const
& e )
118
{
119
Success
=
false
;
120
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, e );
121
}
122
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
123
{
124
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
,
125
ex.what() );
126
throw
daq::dbe::ObjectChangeWasNotSuccessful (
ERS_HERE
, ex );
127
}
128
129
}
130
//------------------------------------------------------------------------------------------
131
132
}
133
}
134
#endif
/* DBE_CHANGE_DATE_HPP_ */
Command.hpp
ConfigObject.hpp
Errors.hpp
Exceptions.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
dbe::actions::ChangeDate::ChangeDate
ChangeDate(tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData, QUndoCommand *parent=nullptr)
Definition
change_date.hpp:54
dbe::actions::ChangeDate::Success
bool Success
Definition
change_date.hpp:50
dbe::actions::ChangeDate::undo
void undo()
Definition
change_date.hpp:77
dbe::actions::ChangeDate::Attribute
dunedaq::conffwk::attribute_t Attribute
Definition
change_date.hpp:49
dbe::actions::ChangeDate::redo
void redo()
Definition
change_date.hpp:102
dbe::actions::ChangeDate::OldValue
T OldValue
Definition
change_date.hpp:47
dbe::actions::ChangeDate::NewValue
T NewValue
Definition
change_date.hpp:48
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_set.hpp
messenger.hpp
FAIL
#define FAIL(...)
Definition
messenger.hpp:133
dbe::actions
Definition
change_attribute.hpp:37
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:238
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