DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
model_common_interface.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/model_common_interface.h to include/dbe/model_common_interface.hpp).
5
6/*
7 * model_common_interface.h
8 *
9 * Created on: Nov 16, 2015
10 * Author: lgeorgop
11 */
12
13#ifndef DBE_MODEL_COMMON_INTERFACE_H_
14#define DBE_MODEL_COMMON_INTERFACE_H_
15
16#include "dbe/confaccessor.hpp"
18
19#include <QString>
20#include <QModelIndex>
21#include <QUuid>
22
23#include <vector>
24#include <set>
25
26#define MODEL_COMMON_INTERFACE_UUID_DEF QUuid const uuid;
27#define MODEL_COMMON_INTERFACE_UUID_DECL uuid(QUuid::createUuid())
28
29#define MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS\
30 typedef QModelIndex type_index;\
31 typedef std::vector<type_index> type_indices;\
32 typedef dbe::tref type_object_ref;\
33 typedef dbe::dref type_object_info;\
34 typedef dunedaq::conffwk::class_t type_class_info;\
35 \
36
37
38namespace dbe
39{
40//------------------------------------------------------------------------------------------
41
43{
45
46public:
47 virtual ~model_common_slots() = default;
48
49private:
50 // These methods should be placed in slots declaration such that they can be parsed
51 // appropriately to create slots at each derived class
60 virtual void slot_remove_object ( QString const &, dref const & ) = 0;
61
71 virtual void slot_rename_object ( QString const &, dref const & ) = 0;
72
82 virtual void slot_update_object ( QString const &, dref const & ) = 0;
83
93 virtual void slot_create_object ( QString const &, dref const & ) = 0;
94};
95//------------------------------------------------------------------------------------------
96
97//------------------------------------------------------------------------------------------
99{
101public:
102 virtual type_object_ref getobject ( type_index const & index ) const = 0;
103
104 virtual type_class_info getclass ( type_index const & index ) const = 0;
105
106 virtual QAbstractItemModel * ReturnSourceModel() const = 0;
107
109};
110//------------------------------------------------------------------------------------------
111
112//------------------------------------------------------------------------------------------
114{
116
117public:
119 //-------------------------- FORWARD CHAIN ------------------------------------------------------------------------
120 // Front end functionality permits explicit actions on the objects linked to this model
121 // These methods should provoke actions onto the database itself
128 virtual bool delete_objects ( type_indices::iterator, type_indices::iterator ) = 0;
129 virtual bool update_objects ( type_indices::iterator, type_indices::iterator ) = 0;
130 virtual bool create_objects ( type_indices::iterator, type_indices::iterator ) = 0;
131};
132//------------------------------------------------------------------------------------------
133
134//------------------------------------------------------------------------------------------
141 private model_common_slots
142{
144
145 friend class model_common_slots;
146public:
147 virtual ~model_common_interface() = default;
148
149protected:
155 virtual void remove_deleted_object ( type_index const & index ) = 0;
156
164 virtual void rename_contained_object ( type_index const & index,
165 type_object_info const & obj ) = 0;
166
174 virtual void update_contained_object ( type_index const & index,
175 type_object_info const & obj ) = 0;
183 virtual void create_contained_object ( type_index const & index,
184 type_object_info const & obj ) = 0;
185
192 virtual type_index lookup ( type_object_info const & ) = 0;
193
194 QUuid getuuid() const;
195};
196//------------------------------------------------------------------------------------------
197
198//------------------------------------------------------------------------------------------
207template<typename T> class model_common_impl:
209{
211
212public:
213
221 bool delete_objects ( type_indices::iterator, type_indices::iterator ) override;
222
229 bool update_objects ( type_indices::iterator, type_indices::iterator ) override;
230
237 bool create_objects ( type_indices::iterator, type_indices::iterator ) override;
238
239// private:
240// FOR FUTURE USE
241// static std::vector<type_object_info> filter_indices(type_indices::iterator,
242// type_indices::iterator);
243};
244//------------------------------------------------------------------------------------------
245
246//------------------------------------------------------------------------------------------
259template<typename T> class model_common_async_operations
260{
261public:
263
265
272
273protected:
274 //-------------------------- BACK CHAIN -------------------------------------------------------------------------------
275 // Back end functionality that permits to implicitly act on an object referenced in this model
276 // These methods should NOT take action onto the database but only on the referenced model
277
283 void remove_object ( type_object_info const & );
284 void create_object ( type_object_info const & );
285 void rename_object ( type_object_info const & );
286 void update_object ( type_object_info const & );
287 void update_multiple_objects ( std::vector<type_object_info> const & );
288
290
291};
292//------------------------------------------------------------------------------------------
293
294}// namespace dbe
295
298
299#endif /* DBE_MODEL_COMMON_INTERFACE_H_ */
void update_multiple_objects(std::vector< type_object_info > const &)
void remove_object(type_object_info const &)
void rename_object(type_object_info const &)
void update_object(type_object_info const &)
MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS model_common_async_operations()
void create_object(type_object_info const &)
bool create_objects(type_indices::iterator, type_indices::iterator) override
bool delete_objects(type_indices::iterator, type_indices::iterator) override
bool update_objects(type_indices::iterator, type_indices::iterator) override
virtual void remove_deleted_object(type_index const &index)=0
virtual void rename_contained_object(type_index const &index, type_object_info const &obj)=0
virtual type_index lookup(type_object_info const &)=0
virtual void update_contained_object(type_index const &index, type_object_info const &obj)=0
virtual ~model_common_interface()=default
virtual void create_contained_object(type_index const &index, type_object_info const &obj)=0
virtual void slot_rename_object(QString const &, dref const &)=0
virtual void slot_update_object(QString const &, dref const &)=0
virtual ~model_common_slots()=default
virtual void slot_remove_object(QString const &, dref const &)=0
virtual void slot_create_object(QString const &, dref const &)=0
virtual bool delete_objects(type_indices::iterator, type_indices::iterator)=0
virtual bool create_objects(type_indices::iterator, type_indices::iterator)=0
virtual ~model_initiate_actions_interface()=default
virtual bool update_objects(type_indices::iterator, type_indices::iterator)=0
#define MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS
#define MODEL_COMMON_INTERFACE_UUID_DEF
Include QT Headers.
config_object_description dref
virtual ~model_common_data_access_interface()=default
virtual type_class_info getclass(type_index const &index) const =0
virtual type_object_ref getobject(type_index const &index) const =0
virtual QAbstractItemModel * ReturnSourceModel() const =0