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/Command.hpp"
17#include "dbe/Exceptions.hpp"
18#include "dbe/confaccessor.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 {
35namespace actions {
36
37template<typename T>
39{
40public:
41 ChangeAttribute(tref Object,
43 T NewValueData,
44 QUndoCommand* parent = nullptr);
45 void undo();
46 void redo();
47
48private:
52};
53
54template<typename T>
57 T NewValueData,
58 QUndoCommand* parent)
59 : onobject(Object, parent)
60 , NewValue(NewValueData)
61 , Attribute(AttributeData)
62{
63 try {
64 failed();
67 toggle();
68 } catch (dunedaq::conffwk::Exception const&) {
69 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
70 FAIL("Operation did not complete because a lookup in the underlying database failed", ex.what());
71 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, ex);
72 }
73
74 setText(
75 QObject::tr("Attribute %1 of object %2 was updated.").arg(AttributeData.p_name.c_str()).arg(Object.UID().c_str()));
76}
77
78template<typename T>
79void
81{
82 try {
83 if (undoable()) {
84 failed();
86 toggle();
87 }
88 } catch (dunedaq::conffwk::Exception const& e) {
89 failed();
90 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
91 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
92 FAIL("Operation did not complete because a lookup in the underlying database failed", ex.what());
93 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, ex);
94 }
95}
96
97template<typename T>
98void
100{
101 try {
102 if (redoable()) {
103 failed();
104
106
107 OldValue = convert::to<T>(Data, Attribute.p_int_format);
108
110 toggle();
111 }
112 } catch (dunedaq::conffwk::Exception const& e) {
113 failed();
114 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
115 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
116 FAIL("Operation did not complete because a lookup in the underlying database failed", ex.what());
117 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, ex);
118 }
119}
120
121}
122}
123#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:412
onobject(tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Definition Command.cpp:403
bool undoable() const
Definition Command.cpp:463
void failed() const
Definition Command.cpp:437
bool redoable() const
Definition Command.cpp:469
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:36