DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
model_common_interface.hpp
Go to the documentation of this file.
1/*
2 * model_common_interface.h
3 *
4 * Created on: Nov 16, 2015
5 * Author: lgeorgop
6 */
7
8#ifndef DBE_MODEL_COMMON_INTERFACE_H_
9#define DBE_MODEL_COMMON_INTERFACE_H_
10
11#include "dbe/confaccessor.hpp"
13
14#include <QString>
15#include <QModelIndex>
16#include <QUuid>
17
18#include <vector>
19#include <set>
20
21#define MODEL_COMMON_INTERFACE_UUID_DEF QUuid const uuid;
22#define MODEL_COMMON_INTERFACE_UUID_DECL uuid(QUuid::createUuid())
23
24#define MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS\
25 typedef QModelIndex type_index;\
26 typedef std::vector<type_index> type_indices;\
27 typedef dbe::tref type_object_ref;\
28 typedef dbe::dref type_object_info;\
29 typedef dunedaq::conffwk::class_t type_class_info;\
30 \
31
32
33namespace dbe
34{
35//------------------------------------------------------------------------------------------
36
38{
40
41public:
42 virtual ~model_common_slots() = default;
43
44private:
45 // These methods should be placed in slots declaration such that they can be parsed
46 // appropriately to create slots at each derived class
55 virtual void slot_remove_object ( QString const &, dref const & ) = 0;
56
66 virtual void slot_rename_object ( QString const &, dref const & ) = 0;
67
77 virtual void slot_update_object ( QString const &, dref const & ) = 0;
78
88 virtual void slot_create_object ( QString const &, dref const & ) = 0;
89};
90//------------------------------------------------------------------------------------------
91
92//------------------------------------------------------------------------------------------
94{
96public:
97 virtual type_object_ref getobject ( type_index const & index ) const = 0;
98
99 virtual type_class_info getclass ( type_index const & index ) const = 0;
100
101 virtual QAbstractItemModel * ReturnSourceModel() const = 0;
102
104};
105//------------------------------------------------------------------------------------------
106
107//------------------------------------------------------------------------------------------
109{
111
112public:
114 //-------------------------- FORWARD CHAIN ------------------------------------------------------------------------
115 // Front end functionality permits explicit actions on the objects linked to this model
116 // These methods should provoke actions onto the database itself
123 virtual bool delete_objects ( type_indices::iterator, type_indices::iterator ) = 0;
124 virtual bool update_objects ( type_indices::iterator, type_indices::iterator ) = 0;
125 virtual bool create_objects ( type_indices::iterator, type_indices::iterator ) = 0;
126};
127//------------------------------------------------------------------------------------------
128
129//------------------------------------------------------------------------------------------
136 private model_common_slots
137{
139
140 friend class model_common_slots;
141public:
142 virtual ~model_common_interface() = default;
143
144protected:
150 virtual void remove_deleted_object ( type_index const & index ) = 0;
151
159 virtual void rename_contained_object ( type_index const & index,
160 type_object_info const & obj ) = 0;
161
169 virtual void update_contained_object ( type_index const & index,
170 type_object_info const & obj ) = 0;
178 virtual void create_contained_object ( type_index const & index,
179 type_object_info const & obj ) = 0;
180
187 virtual type_index lookup ( type_object_info const & ) = 0;
188
189 QUuid getuuid() const;
190};
191//------------------------------------------------------------------------------------------
192
193//------------------------------------------------------------------------------------------
202template<typename T> class model_common_impl:
204{
206
207public:
208
216 bool delete_objects ( type_indices::iterator, type_indices::iterator ) override;
217
224 bool update_objects ( type_indices::iterator, type_indices::iterator ) override;
225
232 bool create_objects ( type_indices::iterator, type_indices::iterator ) override;
233
234// private:
235// FOR FUTURE USE
236// static std::vector<type_object_info> filter_indices(type_indices::iterator,
237// type_indices::iterator);
238};
239//------------------------------------------------------------------------------------------
240
241//------------------------------------------------------------------------------------------
254template<typename T> class model_common_async_operations
255{
256public:
258
260
267
268protected:
269 //-------------------------- BACK CHAIN -------------------------------------------------------------------------------
270 // Back end functionality that permits to implicitly act on an object referenced in this model
271 // These methods should NOT take action onto the database but only on the referenced model
272
278 void remove_object ( type_object_info const & );
279 void create_object ( type_object_info const & );
280 void rename_object ( type_object_info const & );
281 void update_object ( type_object_info const & );
282 void update_multiple_objects ( std::vector<type_object_info> const & );
283
285
286};
287//------------------------------------------------------------------------------------------
288
289}// namespace dbe
290
293
294#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.
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