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/Command.hpp"
17#include "dbe/Exceptions.hpp"
18#include "dbe/confaccessor.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 {
33namespace actions {
34//------------------------------------------------------------------------------------------
35template<typename T>
36class ChangeClass : public onobject
37{
38public:
39 ChangeClass(tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData, QUndoCommand* parent = nullptr);
40 void undo();
41 void redo();
42
43private:
47 bool Success;
48};
49
50template<typename T>
53 T NewValueData,
54 QUndoCommand* parent)
55 : onobject(Object, parent)
56 , NewValue(NewValueData)
57 , Attribute(AttributeData)
58 , Success(true)
59{
60 try {
63 } catch (dunedaq::conffwk::Exception const&) {
64 }
65
66 setText(
67 QObject::tr("Attribute %1 of object %2 was updated.").arg(AttributeData.p_name.c_str()).arg(Object.UID().c_str()));
68}
69
70template<typename T>
71void
73{
74 try {
75 if (isvalid()) {
76 failed();
78 toggle();
79 }
80 } catch (dunedaq::conffwk::Exception const& e) {
81 Success = false;
82 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
83 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
84 FAIL("Operation did not complete because a lookup in the underlying database failed", ex.what());
85 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, ex);
86 }
87}
88
89template<typename T>
90void
92{
93 try {
94 if (isvalid()) {
95 failed();
98
100 toggle();
101 }
102 } catch (dunedaq::conffwk::Exception const& e) {
103 Success = false;
104 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
105 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
106 FAIL("Operation did not complete because a lookup in the underlying database failed", ex.what());
107 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, ex);
108 }
109}
110
111}
112}
113#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:412
onobject(tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Definition Command.cpp:403
bool isvalid() const
Definition Command.cpp:445
void failed() const
Definition Command.cpp:437
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:36