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/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 <QString>
28#include <string>
29
30namespace dbe {
31namespace actions {
32
33//------------------------------------------------------------------------------------------
34template<typename T>
35class ChangeDate : public onobject
36{
37public:
38 ChangeDate(tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData, QUndoCommand* parent = nullptr);
39 void undo();
40 void redo();
41
42private:
46 bool Success;
47};
48
49template<typename T>
52 T NewValueData,
53 QUndoCommand* parent)
54 : onobject(Object, parent)
55 , NewValue(NewValueData)
56 , Attribute(AttributeData)
57 , Success(true)
58{
59 try {
62 } catch (dunedaq::conffwk::Exception const&) {
63 }
64
65 setText(
66 QObject::tr("Attribute %1 of object %2 was updated.").arg(AttributeData.p_name.c_str()).arg(Object.UID().c_str()));
67}
68
69template<typename T>
70void
72{
73 try {
74 if (isvalid()) {
75 failed();
77 toggle();
78 }
79 } catch (dunedaq::conffwk::Exception const& e) {
80 Success = false;
81 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
82 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
83 FAIL("Operation did not complete because a lookup in the underlying database failed", ex.what());
84 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, ex);
85 }
86}
87template<typename T>
88void
90{
91 try {
92 if (isvalid()) {
93 failed();
96
98 toggle();
99 }
100 } catch (dunedaq::conffwk::Exception const& e) {
101 Success = false;
102 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
103 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
104 FAIL("Operation did not complete because a lookup in the underlying database failed", ex.what());
105 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, ex);
106 }
107}
108//------------------------------------------------------------------------------------------
109
110}
111}
112#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: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 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:36