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/Command.hpp
"
17
#include "
dbe/Exceptions.hpp
"
18
#include "
dbe/confaccessor.hpp
"
19
#include "
dbe/config_api_set.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
namespace
actions
{
32
33
//------------------------------------------------------------------------------------------
34
template
<
typename
T>
35
class
ChangeDate
:
public
onobject
36
{
37
public
:
38
ChangeDate
(
tref
Object,
dunedaq::conffwk::attribute_t
AttributeData, T NewValueData, QUndoCommand* parent =
nullptr
);
39
void
undo
();
40
void
redo
();
41
42
private
:
43
T
OldValue
;
44
T
NewValue
;
45
dunedaq::conffwk::attribute_t
Attribute
;
46
bool
Success
;
47
};
48
49
template
<
typename
T>
50
ChangeDate<T>::ChangeDate
(
tref
Object,
51
dunedaq::conffwk::attribute_t
AttributeData,
52
T NewValueData,
53
QUndoCommand* parent)
54
:
onobject
(Object, parent)
55
,
NewValue
(NewValueData)
56
,
Attribute
(AttributeData)
57
,
Success
(true)
58
{
59
try
{
60
QStringList Data{
dbe::config::api::get::attribute::list<QStringList>
(Object,
Attribute
) };
61
OldValue
=
convert::to<T>
(Data);
62
}
catch
(dunedaq::conffwk::Exception
const
&) {
63
}
64
65
setText(
66
QObject::tr(
"Attribute %1 of object %2 was updated."
).arg(AttributeData.
p_name
.c_str()).arg(Object.
UID
().c_str()));
67
}
68
69
template
<
typename
T>
70
void
71
ChangeDate<T>::undo
()
72
{
73
try
{
74
if
(
isvalid
()) {
75
failed
();
76
dbe::config::api::set::noactions::adate
(this->
checkedref
(),
Attribute
,
OldValue
);
77
toggle
();
78
}
79
}
catch
(dunedaq::conffwk::Exception
const
& e) {
80
Success
=
false
;
81
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, e);
82
}
catch
(daq::dbe::config_object_retrieval_result_is_null
const
& ex) {
83
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
, ex.what());
84
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, ex);
85
}
86
}
87
template
<
typename
T>
88
void
89
ChangeDate<T>::redo
()
90
{
91
try
{
92
if
(
isvalid
()) {
93
failed
();
94
QStringList Data{
dbe::config::api::get::attribute::list<QStringList>
(this->
checkedref
(),
Attribute
) };
95
OldValue
=
convert::to<T>
(Data);
96
97
dbe::config::api::set::noactions::adate
(this->
checkedref
(),
Attribute
,
NewValue
);
98
toggle
();
99
}
100
}
catch
(dunedaq::conffwk::Exception
const
& e) {
101
Success
=
false
;
102
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, e);
103
}
catch
(daq::dbe::config_object_retrieval_result_is_null
const
& ex) {
104
FAIL
(
"Operation did not complete because a lookup in the underlying database failed"
, ex.what());
105
throw
daq::dbe::ObjectChangeWasNotSuccessful(
ERS_HERE
, ex);
106
}
107
}
108
//------------------------------------------------------------------------------------------
109
110
}
111
}
112
#endif
/* DBE_CHANGE_DATE_HPP_ */
Command.hpp
ConfigObject.hpp
Errors.hpp
Exceptions.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:127
dbe::actions::ChangeDate::ChangeDate
ChangeDate(tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData, QUndoCommand *parent=nullptr)
Definition
change_date.hpp:50
dbe::actions::ChangeDate::Success
bool Success
Definition
change_date.hpp:46
dbe::actions::ChangeDate::undo
void undo()
Definition
change_date.hpp:71
dbe::actions::ChangeDate::Attribute
dunedaq::conffwk::attribute_t Attribute
Definition
change_date.hpp:45
dbe::actions::ChangeDate::redo
void redo()
Definition
change_date.hpp:89
dbe::actions::ChangeDate::OldValue
T OldValue
Definition
change_date.hpp:43
dbe::actions::ChangeDate::NewValue
T NewValue
Definition
change_date.hpp:44
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::isvalid
bool isvalid() const
Definition
Command.cpp:445
dbe::actions::state::failed
void failed() const
Definition
Command.cpp:437
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_set.hpp
messenger.hpp
FAIL
#define FAIL(...)
Definition
messenger.hpp:129
dbe::actions
Definition
change_attribute.hpp:35
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:192
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_name
std::string p_name
Definition
Schema.hpp:62
Generated on
for DUNE-DAQ by
1.18.0