DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
change_class.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_class.hpp to include/dbe/change_class.hpp).
5
6/*
7 * change_class.hpp
8 *
9 * Created on: Nov 10, 2015
10 * Author: lgeorgop
11 */
12
13#ifndef DBE_CHANGE_CLASS_HPP_
14#define DBE_CHANGE_CLASS_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 <QtCore/qstring.h>
28#include <QtCore/qstringlist.h>
29
30#include <string>
31
32namespace dbe
33{
34namespace actions
35{
36//------------------------------------------------------------------------------------------
37template<typename T>
39 public onobject
40{
41public:
42 ChangeClass ( tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData,
43 QUndoCommand * parent = nullptr );
44 void undo();
45 void redo();
46
47private:
51 bool Success;
52};
53
54template<typename T>
56 T NewValueData, QUndoCommand * parent )
57 : onobject ( Object, parent ),
58 NewValue ( NewValueData ),
59 Attribute ( AttributeData ),
60 Success ( true )
61{
62 try
63 {
64 QStringList Data
66 OldValue = convert::to<T> ( Data );
67 }
68 catch ( dunedaq::conffwk::Exception const & )
69 {
70 }
71
72 setText (
73 QObject::tr ( "Attribute %1 of object %2 was updated." ).arg (
74 AttributeData.p_name.c_str() ).arg ( Object.UID().c_str() ) );
75}
76
77template<typename T>
79{
80 try
81 {
82 if ( isvalid() )
83 {
84 failed();
86 toggle();
87 }
88 }
89 catch ( dunedaq::conffwk::Exception const & e )
90 {
91 Success = false;
92 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, e );
93 }
94 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
95 {
96 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
97 ex.what() );
98 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, ex );
99 }
100
101}
102
103template<typename T>
105{
106 try
107 {
108 if ( isvalid() )
109 {
110 failed();
111 QStringList Data
113 OldValue = convert::to<T> ( Data );
114
116 toggle();
117 }
118 }
119 catch ( dunedaq::conffwk::Exception const & e )
120 {
121 Success = false;
122 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, e );
123 }
124 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
125 {
126 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
127 ex.what() );
128 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, ex );
129 }
130
131}
132
133}
134}
135#endif // DBE_CHANGE_CLASS_HPP_
#define ERS_HERE
ChangeClass(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 aclass(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