DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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"
18#include "dbe/Command.hpp"
19#include "dbe/Exceptions.hpp"
20#include "dbe/messenger.hpp"
21
23#include "conffwk/Errors.hpp"
24#include "conffwk/Schema.hpp"
25
26#include <QObject>
27#include <QString>
28#include <string>
29
30namespace dbe
31{
32namespace actions
33{
34
35//------------------------------------------------------------------------------------------
36template<typename T>
38 public onobject
39{
40public:
41 ChangeDate ( 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 ( isvalid() )
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}
101template<typename T>
103{
104 try
105 {
106 if ( isvalid() )
107 {
108 failed();
109 QStringList Data
111 OldValue = convert::to<T> ( Data );
112
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_ */
#define ERS_HERE
ChangeDate(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 isvalid() const
Definition Command.cpp:548
void failed() const
Definition Command.cpp:541
static T list(dbe::inner::configobject::tref obj, dunedaq::conffwk::attribute_t const &attr)
#define FAIL(...)
void adate(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