DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
model_common_interface_macros.hpp
Go to the documentation of this file.
1/*
2 * model_common_interface_macros.h
3 *
4 * Created on: Dec 7, 2015
5 * Author: lgeorgop
6 */
7
8#ifndef DBE_MODEL_COMMON_INTERFACE_MACROS_H_
9#define DBE_MODEL_COMMON_INTERFACE_MACROS_H_
10
12
13//------------------------------------------------------------------------------------------
14#define MODEL_COMMON_INTERFACE_TYPES(classname)\
15 \
16 typedef model_common_async_operations<classname>::type_index type_index;\
17 typedef model_common_async_operations<classname>::type_indices type_indices;\
18 typedef model_common_async_operations<classname>::type_object_ref type_object_ref;\
19 typedef model_common_async_operations<classname>::type_class_info type_class_info;\
20 typedef model_common_async_operations<classname>::type_object_info type_object_info;\
21 \
22//------------------------------------------------------------------------------------------
23
24//------------------------------------------------------------------------------------------
25#define MODEL_COMMON_IMPL_REQ_DEF(classname) \
26 \
27 friend class model_common_async_operations<classname>;\
28 friend class model_common_impl<classname>;\
29 \
30 public:\
31 QModelIndex lookup(dbe::dref const &) override; \
32 \
33 MODEL_COMMON_INTERFACE_TYPES(classname)\
34 \
35 type_object_ref getobject(type_index const &index) const override; \
36 type_class_info getclass(const QModelIndex & index) const override; \
37 QAbstractItemModel* ReturnSourceModel() const override; \
38 \
39 private:\
40 \
41 void remove_deleted_object(type_index const & index) override; \
42 void create_contained_object(type_index const & index, \
43 type_object_info const & obj) override; \
44 void rename_contained_object(type_index const & index, \
45 type_object_info const & obj) override; \
46 void update_contained_object(type_index const & index, \
47 type_object_info const & obj) override; \
48 \
49 bool removeRows(int row, int count, type_index const & parent) override;\
50 \
51//------------------------------------------------------------------------------------------
52
53//------------------------------------------------------------------------------------------
54#define MODEL_COMMON_INTERFACE_REQ_DEF(classname) \
55 \
56 MODEL_COMMON_IMPL_REQ_DEF(classname) \
57 \
58 public:\
59 \
60 bool delete_objects(type_indices::iterator , type_indices::iterator ) override; \
61 bool create_objects(type_indices::iterator , type_indices::iterator ) override; \
62 bool update_objects(type_indices::iterator , type_indices::iterator ) override; \
63 \
64 private:\
65 \
66
67//------------------------------------------------------------------------------------------
68
69//------------------------------------------------------------------------------------------
70#define MODEL_REMOVE_ROWS_DEF(classname) \
71 bool classname::removeRows(int row, int count, type_index const & parent)
72//------------------------------------------------------------------------------------------
73
74//------------------------------------------------------------------------------------------
75#define MODEL_DELETE_OBJECTS_DEF(classname) \
76 bool classname::delete_objects(type_indices::iterator b , type_indices::iterator e) \
77
78#define MODEL_CREATE_OBJECTS_DEF(classname) \
79 bool classname::create_objects(type_indices::iterator b, type_indices::iterator e) \
80
81#define MODEL_UPDATE_OBJECTS_DEF(classname) \
82 bool classname::update_objects(type_indices::iterator b, type_indices::iterator e) \
83
84#define MODEL_RENAME_OBJECTS_DEF(classname) \
85 bool classname::rename_objects(type_indices::iterator b, type_indices::iterator e) \
86//------------------------------------------------------------------------------------------
87
88//------------------------------------------------------------------------------------------
89/*
90 * Below are macros that facilitate to define the methods required by model interface
91 */
92
98#define MODEL_COMMON_INTERFACE_LOOKUP_IMPL(classname) \
99 QModelIndex classname::lookup(type_object_info const & obj) \
100
105#define MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL(classname) \
106 void classname::remove_deleted_object(type_index const & index) \
107
112#define MODEL_COMMON_INTERFACE_CREATE_THAT_OBJ_IMPL(classname) \
113 void classname::create_contained_object(type_index const & index, \
114 type_object_info const & obj) \
115
120#define MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL(classname) \
121 void classname::rename_contained_object(type_index const & index, \
122 type_object_info const & obj) \
123
128#define MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL(classname) \
129 void classname::update_contained_object(type_index const & index, \
130 type_object_info const & obj) \
131
132//------------------------------------------------------------------------------------------
133
134//------------------------------------------------------------------------------------------
135// INCLUDE this macro in the derived class source file
136//
137// Slots need be defined in the header file of the derived class directly for Qt
138// to be aware and generate the code needed , this forces the definition in the source file
139// of the derived class for the slots, which can be uniformly achieved with this macro.
140#define MODEL_COMMON_INTERFACE_SLOTS_DEF(classname) \
141 void classname::slot_remove_object(QString const & src, type_object_info const & obj)\
142 {\
143 if(uuid.toString() != src) \
144 { \
145 remove_object(obj); \
146 }\
147 }\
148 \
149 void classname::slot_update_object(QString const & src, type_object_info const & obj)\
150 {\
151 if(uuid.toString() != src) \
152 { \
153 update_object(obj); \
154 }\
155 }\
156 \
157 void classname::slot_rename_object(QString const & src, type_object_info const & obj)\
158 {\
159 if(uuid.toString() != src) \
160 { \
161 rename_object(obj); \
162 }\
163 }\
164 \
165 void classname::slot_create_object(QString const & src, type_object_info const & obj)\
166 {\
167 if(uuid.toString() != src) \
168 { \
169 create_object(obj); \
170 }\
171 }\
172
173//------------------------------------------------------------------------------------------
174
175#endif /* DBE_MODEL_COMMON_INTERFACE_MACROS_H_ */