DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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
17#include "dbe/Command.hpp"
18#include "dbe/Exceptions.hpp"
19#include "dbe/confaccessor.hpp"
20
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
31namespace dbe
32{
33namespace actions
34{
35//------------------------------------------------------------------------------------------
36template<typename T>
38 public onobject
39{
40public:
41 ChangeTime ( tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData,
42 QUndoCommand * parent = nullptr );
43 void undo();
44 void redo();
45
46private:
50 bool Success;
51};
52
53template<typename T>
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
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
76template<typename T>
78{
79 try
80 {
81 if ( undoable() )
82 {
83 failed();
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
102template<typename T>
104{
105 try
106 {
107 if ( redoable() )
108 {
109 failed();
110
111 QStringList Data
113
114 OldValue = convert::to<T> ( Data );
115
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_ */
#define ERS_HERE
ChangeTime(tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData, QUndoCommand *parent=nullptr)
dunedaq::conffwk::attribute_t Attribute
tref checkedref() const
Definition Command.cpp:518
onobject(tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Definition Command.cpp:510
bool undoable() const
Definition Command.cpp:563
void failed() const
Definition Command.cpp:541
bool redoable() const
Definition Command.cpp:568
static T list(dbe::inner::configobject::tref obj, dunedaq::conffwk::attribute_t const &attr)
#define FAIL(...)
void atime(inner::configobject::tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T NewValueData, bool NotEmit=false)
T to(QStringList const &DataList)
Include QT Headers.
inner::configobject::tref tref
Definition tref.hpp:35