DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
change_attribute.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_attribute.hpp to include/dbe/change_attribute.hpp).
5
6/*
7 * change_attribute.hpp
8 *
9 * Created on: Nov 10, 2015
10 * Author: lgeorgop
11 */
12
13#ifndef DBE_CHANGE_ATTRIBUTE_HPP_
14#define DBE_CHANGE_ATTRIBUTE_HPP_
15
16#include "dbe/confaccessor.hpp"
19#include "dbe/Command.hpp"
20#include "dbe/Exceptions.hpp"
21
23#include "conffwk/Errors.hpp"
24#include "conffwk/Schema.hpp"
25
26#include <QtCore/qobject.h>
27#include <QtCore/qstring.h>
28#include <QtCore/qstringlist.h>
29
30#include <string>
31
32#include "dbe/messenger.hpp"
33
34namespace dbe
35{
36namespace actions
37{
38
39template<typename T>
41 public onobject
42{
43public:
44 ChangeAttribute ( tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData,
45 QUndoCommand * parent = nullptr );
46 void undo();
47 void redo();
48private:
52};
53
54template<typename T>
56 T NewValueData, QUndoCommand * parent )
57 : onobject ( Object, parent ),
58 NewValue ( NewValueData ),
59 Attribute ( AttributeData )
60{
61 try
62 {
63 failed();
64 QStringList Data
66 OldValue = convert::to<T> ( Data, Attribute.p_int_format );
67 toggle();
68 }
69 catch ( dunedaq::conffwk::Exception const & )
70 {
71 }
72 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
73 {
74 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
75 ex.what() );
76 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, ex );
77 }
78
79 setText (
80 QObject::tr ( "Attribute %1 of object %2 was updated." ).arg (
81 AttributeData.p_name.c_str() ).arg ( Object.UID().c_str() ) );
82}
83
84template<typename T>
86{
87 try
88 {
89 if ( undoable() )
90 {
91 failed();
93 toggle();
94 }
95 }
96 catch ( dunedaq::conffwk::Exception const & e )
97 {
98 failed();
99 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, e );
100 }
101 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
102 {
103 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
104 ex.what() );
105 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, ex );
106 }
107
108}
109
110template<typename T>
112{
113 try
114 {
115 if ( redoable() )
116 {
117 failed();
118
119 QStringList Data
121
122 OldValue = convert::to<T> ( Data, Attribute.p_int_format );
123
125 toggle();
126 }
127 }
128 catch ( dunedaq::conffwk::Exception const & e )
129 {
130 failed();
131 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, e );
132 }
133 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
134 {
135 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
136 ex.what() );
137 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, ex );
138 }
139
140}
141
142}
143}
144#endif /* DBE_CHANGE_ATTRIBUTE_HPP_ */
#define ERS_HERE
ChangeAttribute(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 attribute(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