DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
change_time.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_time.hpp to include/dbe/change_time.hpp).
5
6/*
7 * change_time.hpp
8 *
9 * Created on: Nov 10, 2015
10 * Author: lgeorgop
11 */
12
13#ifndef DBE_CHANGE_TIME_HPP_
14#define DBE_CHANGE_TIME_HPP_
15
16#include "dbe/Command.hpp"
17#include "dbe/Exceptions.hpp"
18#include "dbe/confaccessor.hpp"
20
22#include "conffwk/Errors.hpp"
23#include "conffwk/Schema.hpp"
24
25#include <QObject>
26#include <QtCore/qstring.h>
27#include <QtCore/qstringlist.h>
28
29#include <string>
30
31namespace dbe {
32namespace actions {
33//------------------------------------------------------------------------------------------
34template<typename T>
35class ChangeTime : public onobject
36{
37public:
38 ChangeTime(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 (undoable()) {
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}
87
88template<typename T>
89void
91{
92 try {
93 if (redoable()) {
94 failed();
95
97
99
101 toggle();
102 }
103 } catch (dunedaq::conffwk::Exception const& e) {
104 Success = false;
105 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
106 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
107 FAIL("Operation did not complete because a lookup in the underlying database failed", ex.what());
108 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, ex);
109 }
110}
111//------------------------------------------------------------------------------------------
112}
113}
114// namespace dbe
115#endif /* DBE_CHANGE_TIME_HPP_ */
#define ERS_HERE
ChangeTime(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 atime(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