DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
change_date.hpp
Go to the documentation of this file.
1/*
2 * change_date.hpp
3 *
4 * Created on: Nov 10, 2015
5 * Author: lgeorgop
6 */
7
8#ifndef DBE_CHANGE_DATE_HPP_
9#define DBE_CHANGE_DATE_HPP_
10
11#include "dbe/confaccessor.hpp"
13#include "dbe/Command.hpp"
14#include "dbe/Exceptions.hpp"
15#include "dbe/messenger.hpp"
16
18#include "conffwk/Errors.hpp"
19#include "conffwk/Schema.hpp"
20
21#include <QObject>
22#include <QString>
23#include <string>
24
25namespace dbe
26{
27namespace actions
28{
29
30//------------------------------------------------------------------------------------------
31template<typename T>
33 public onobject
34{
35public:
36 ChangeDate ( tref Object, dunedaq::conffwk::attribute_t AttributeData, T NewValueData,
37 QUndoCommand * parent = nullptr );
38 void undo();
39 void redo();
40
41private:
45 bool Success;
46};
47
48template<typename T>
50 T NewValueData, QUndoCommand * parent )
51 : onobject ( Object, parent ),
52 NewValue ( NewValueData ),
53 Attribute ( AttributeData ),
54 Success ( true )
55{
56 try
57 {
58 QStringList Data
60 OldValue = convert::to<T> ( Data );
61 }
62 catch ( dunedaq::conffwk::Exception const & )
63 {
64 }
65
66 setText (
67 QObject::tr ( "Attribute %1 of object %2 was updated." ).arg (
68 AttributeData.p_name.c_str() ).arg ( Object.UID().c_str() ) );
69}
70
71template<typename T>
73{
74 try
75 {
76 if ( isvalid() )
77 {
78 failed();
79 dbe::config::api::set::noactions::adate ( this->checkedref(), Attribute, OldValue );
80 toggle();
81 }
82 }
83 catch ( dunedaq::conffwk::Exception const & e )
84 {
85 Success = false;
86 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, e );
87 }
88 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
89 {
90 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
91 ex.what() );
92 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, ex );
93 }
94
95}
96template<typename T>
98{
99 try
100 {
101 if ( isvalid() )
102 {
103 failed();
104 QStringList Data
105 { dbe::config::api::get::attribute::list<QStringList> ( this->checkedref(), Attribute ) };
106 OldValue = convert::to<T> ( Data );
107
108 dbe::config::api::set::noactions::adate ( this->checkedref(), Attribute, NewValue );
109 toggle();
110 }
111 }
112 catch ( dunedaq::conffwk::Exception const & e )
113 {
114 Success = false;
115 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, e );
116 }
117 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
118 {
119 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
120 ex.what() );
121 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, ex );
122 }
123
124}
125//------------------------------------------------------------------------------------------
126
127}
128}
129#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
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.