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