Bayeux
3.4.1
Core Foundation library for SuperNEMO
bayeux
datatools
detail
reflection_macros.h
Go to the documentation of this file.
1
/*
4
* Copyright (C) 2012-2016 Francois Mauger <mauger@lpccaen.in2p3.fr>
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or (at
9
* your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
20
*
21
*/
22
23
#ifndef DATATOOLS_DETAIL_REFLECTION_MACROS_H
24
#define DATATOOLS_DETAIL_REFLECTION_MACROS_H
25
26
// Standard Library:
27
#include <string>
28
29
// Special Boost headers :
30
#include <boost/function.hpp>
31
#include <boost/bind.hpp>
32
#include <boost/ref.hpp>
33
34
// Third Party:
35
// - Camp:
36
#include <camp/camptype.hpp>
37
#include <camp/class.hpp>
38
#include <camp/enum.hpp>
39
#include <camp/value.hpp>
40
#include <camp/function.hpp>
41
#include <camp/property.hpp>
42
#include <camp/arrayproperty.hpp>
43
#include <camp/enumobject.hpp>
44
#include <camp/userobject.hpp>
45
#include <camp/classvisitor.hpp>
46
#include <camp/simpleproperty.hpp>
47
#include <camp/arrayproperty.hpp>
48
#include <camp/enumproperty.hpp>
49
#include <camp/userproperty.hpp>
50
#include <camp/observer.hpp>
51
#include <camp/args.hpp>
52
#include <camp/function.hpp>
53
#include <camp/errors.hpp>
54
55
// This project :
56
#include <
datatools/detail/reflection_utils.h
>
57
58
59
/****************************************
60
* Introspection metaclass macros *
61
****************************************/
62
66
#define DR_CLASS_IMPLEMENT_REFLECTION_HEAD(TypeId,TypeTag) \
67
template<> \
68
void implement_reflection< TypeId > (unsigned int TypeTag) \
69
70
73
#define DR_TYPE_IMPLEMENT_REFLECTION_HEAD(TypeId,TypeTag) \
74
DR_CLASS_IMPLEMENT_REFLECTION_HEAD(TypeId,TypeTag) \
75
76
79
#define DR_CLASS_DECLARE2(ClassId,ClassName) \
80
::camp::Class::declare< ClassId >(ClassName) \
81
82
85
#define DR_CLASS_DECLARE(ClassId) \
86
DR_CLASS_DECLARE2( ClassId , ::datatools::detail::reflection::guid< ClassId >() ) \
87
88
91
#define DR_CLASS_BASE(ParentTypeId) \
92
base< ParentTypeId >() \
93
94
97
#define DR_CLASS_CONSTRUCTOR() \
98
constructor0() \
99
100
103
#define DR_CLASS_CONSTRUCTOR1(Arg0Type) \
104
constructor1< Arg0Type >() \
105
106
109
#define DR_CLASS_CONSTRUCTOR2(Arg0Type,Arg1Type) \
110
constructor2< Arg0Type , Arg1Type >() \
111
112
115
#define DR_CLASS_CONSTRUCTOR3(Arg0Type,Arg1Type,Arg2Type) \
116
constructor3< Arg0Type , Arg1Type , Arg2Type >() \
117
118
121
#define DR_CLASS_CONSTRUCTOR4(Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
122
constructor4< Arg0Type , Arg1Type , Arg2Type , Arg3Type >() \
123
124
128
#define DR_CLASS_CONSTRUCTOR5(Arg0Type,Arg1Type,Arg2Type,Arg3Type,Arg4Type) \
129
constructor5< Arg0Type , Arg1Type , Arg2Type , Arg3Type , Arg4Type >() \
130
131
132
// Declare metadata static flag tag for a class :
133
#define DR_CLASS_TAG_FLAG(TagName) \
134
tag(TagName) \
135
136
137
// Declare metadata static tag with value for a class :
138
#define DR_CLASS_TAG(TagName,TagValue) \
139
tag(TagName, TagValue) \
140
141
142
// Declare metadata read-only property for a class :
143
#define DR_CLASS_PROPERTY_GETTER(PropertyName,PropertyGetterId) \
144
property(PropertyName, &PropertyGetterId) \
145
146
147
// Declare metadata read-only property for a class :
148
#define DR_CLASS_PROPERTY_REFGETTER(PropertyName,RefPropertyGetterId) \
149
property(PropertyName, RefPropertyGetterId) \
150
151
152
// Declare metadata read-write property for a class :
153
#define DR_CLASS_PROPERTY_GETTER_SETTER(PropertyName,PropertyGetterId,PropertySetterId) \
154
property(PropertyName, &PropertyGetterId, &PropertySetterId) \
155
156
157
// Declare metadata read-write property for a class :
158
#define DR_CLASS_PROPERTY_REFGETTER_REFSETTER(PropertyName,RefPropertyGetterId,RefPropertySetterId) \
159
property(PropertyName, RefPropertyGetterId, RefPropertySetterId) \
160
161
162
// Declare metadata read-write property for a class :
163
#define DR_CLASS_PROPERTY_GETTER_SETTER_GETTER(PropertyName,PropertyGetterId,PropertySetterId,PropertyGetterId2) \
164
property(PropertyName, &PropertyGetterId, &PropertySetterId, &PropertyGetterId2) \
165
166
167
// Declare metadata read-write property for a class :
168
#define DR_CLASS_PROPERTY_REFGETTER_REFSETTER_REFGETTER(PropertyName,RefPropertyGetterId,RefPropertySetterId,RefPropertyGetterId2) \
169
property(PropertyName, RefPropertyGetterId, RefPropertySetterId, RefPropertyGetterId2) \
170
171
172
/***************************************
173
* Macros for methods with no argument *
174
***************************************/
175
176
// Declare metadata property for a class method :
177
#define DR_CLASS_METHOD(MethodName,TypeId,MethodId,ReturnType) \
178
function(MethodName, \
179
boost::function< ReturnType ( TypeId & )> \
180
(boost::bind(& MethodId , _1))) \
181
182
183
// Declare metadata property for a class method :
184
#define DR_CLASS_REFMETHOD(MethodName,TypeId,RefMethodId,ReturnType) \
185
function(MethodName, \
186
boost::function< ReturnType ( TypeId & )> \
187
(boost::bind(RefMethodId , _1))) \
188
189
190
// Declare metadata property for a class method :
191
#define DR_CLASS_VOID_METHOD(MethodName,TypeId,MethodId) \
192
DR_CLASS_METHOD(MethodName,TypeId,MethodId,void) \
193
194
195
// Declare metadata property for a class method :
196
#define DR_CLASS_VOID_REFMETHOD(MethodName,TypeId,RefMethodId) \
197
DR_CLASS_REFMETHOD(MethodName,TypeId,RefMethodId,void) \
198
199
200
// Declare metadata property for a class method (const) :
201
#define DR_CLASS_METHOD_CONST(MethodName,TypeId,MethodId,ReturnType) \
202
function(MethodName, \
203
boost::function< ReturnType ( const TypeId & )> \
204
(boost::bind(& MethodId , _1 ))) \
205
206
207
// Declare metadata property for a class method (const) :
208
#define DR_CLASS_REFMETHOD_CONST(MethodName,TypeId,RefMethodId,ReturnType) \
209
function(MethodName, \
210
boost::function< ReturnType ( const TypeId & )> \
211
(boost::bind(RefMethodId , _1 ))) \
212
213
214
// Declare metadata property for a class method (const) :
215
#define DR_CLASS_VOID_METHOD_CONST(MethodName,TypeId,MethodId) \
216
DR_CLASS_METHOD_CONST(MethodName,TypeId,MethodId,void) \
217
218
219
// Declare metadata property for a class method (const) :
220
#define DR_CLASS_VOID_REFMETHOD_CONST(MethodName,TypeId,RefMethodId) \
221
DR_CLASS_REFMETHOD_CONST(MethodName,TypeId,MethodId,void) \
222
223
224
225
226
/**************************************
227
* Macros for methods with 1 argument *
228
**************************************/
229
230
// Declare metadata property for a class method :
231
#define DR_CLASS_METHOD1(MethodName,TypeId,MethodId,ReturnType,Arg0Type) \
232
function(MethodName, \
233
boost::function< ReturnType ( TypeId & , Arg0Type )> \
234
(boost::bind(& MethodId , _1, _2))) \
235
236
237
// Declare metadata property for a class method :
238
#define DR_CLASS_VOID_METHOD1(MethodName,TypeId,MethodId,Arg0Type) \
239
DR_CLASS_METHOD1(MethodName,TypeId,MethodId,void,Arg0Type) \
240
241
242
// Declare metadata property for a class method (const) :
243
#define DR_CLASS_METHOD1_CONST(MethodName,TypeId,MethodId,ReturnType,Arg0Type) \
244
function(MethodName, \
245
boost::function< ReturnType ( const TypeId & , Arg0Type )> \
246
(boost::bind(& MethodId , _1, _2 ))) \
247
248
249
// Declare metadata property for a class method (const) :
250
#define DR_CLASS_VOID_METHOD1_CONST(MethodName,TypeId,MethodId,Arg0Type) \
251
DR_CLASS_METHOD1_CONST(MethodName,TypeId,MethodId,void,Arg0Type) \
252
253
254
// Declare metadata property for a class method :
255
#define DR_CLASS_REFMETHOD1(MethodName,TypeId,RefMethodId,ReturnType,Arg0Type) \
256
function(MethodName, \
257
boost::function< ReturnType ( TypeId & , Arg0Type )> \
258
(boost::bind(RefMethodId , _1, _2))) \
259
260
261
// Declare metadata property for a class method :
262
#define DR_CLASS_VOID_REFMETHOD1(MethodName,TypeId,RefMethodId,Arg0Type) \
263
DR_CLASS_REFMETHOD1(MethodName,TypeId,RefMethodId,void,Arg0Type) \
264
265
266
// Declare metadata property for a class method (const) :
267
#define DR_CLASS_REFMETHOD1_CONST(MethodName,TypeId,RefMethodId,ReturnType,Arg0Type) \
268
function(MethodName, \
269
boost::function< ReturnType ( const TypeId & , Arg0Type )> \
270
(boost::bind(RefMethodId , _1, _2 ))) \
271
272
273
// Declare metadata property for a class method (const) :
274
#define DR_CLASS_VOID_REFMETHOD1_CONST(MethodName,TypeId,RefMethodId,Arg0Type) \
275
DR_CLASS_REFMETHOD1_CONST(MethodName,TypeId,RefMethodId,void,Arg0Type) \
276
277
278
279
/***************************************
280
* Macros for methods with 2 arguments *
281
***************************************/
282
283
// Declare metadata property for a class method :
284
#define DR_CLASS_METHOD2(MethodName,TypeId,MethodId,ReturnType,Arg0Type,Arg1Type) \
285
function(MethodName, \
286
boost::function< ReturnType ( TypeId & , Arg0Type , Arg1Type )> \
287
(boost::bind(& MethodId , _1, _2, _3))) \
288
289
290
// Declare metadata property for a class method :
291
#define DR_CLASS_VOID_METHOD2(MethodName,TypeId,MethodId,Arg0Type,Arg1Type) \
292
DR_CLASS_METHOD2(MethodName,TypeId,MethodId,void,Arg0Type,Arg1Type) \
293
294
295
// Declare metadata property for a class method (const) :
296
#define DR_CLASS_METHOD2_CONST(MethodName,TypeId,MethodId,ReturnType,Arg0Type,Arg1Type) \
297
function(MethodName, \
298
boost::function< ReturnType ( const TypeId & , Arg0Type , Arg1Type )> \
299
(boost::bind(& MethodId , _1, _2, _3 ))) \
300
301
302
// Declare metadata property for a class method (const) :
303
#define DR_CLASS_VOID_METHOD2_CONST(MethodName,TypeId,MethodId,Arg0Type,Arg1Type) \
304
DR_CLASS_METHOD2_CONST(MethodName,TypeId,MethodId,void,Arg0Type,Arg1Type) \
305
306
307
// Declare metadata property for a class method :
308
#define DR_CLASS_REFMETHOD2(MethodName,TypeId,RefMethodId,ReturnType,Arg0Type,Arg1Type) \
309
function(MethodName, \
310
boost::function< ReturnType ( TypeId & , Arg0Type , Arg1Type )> \
311
(boost::bind(RefMethodId , _1, _2, _3))) \
312
313
314
// Declare metadata property for a class method :
315
#define DR_CLASS_VOID_REFMETHOD2(MethodName,TypeId,RefMethodId,Arg0Type,Arg1Type) \
316
DR_CLASS_REFMETHOD2(MethodName,TypeId,RefMethodId,void,Arg0Type,Arg1Type) \
317
318
319
// Declare metadata property for a class method (const) :
320
#define DR_CLASS_REFMETHOD2_CONST(MethodName,TypeId,RefMethodId,ReturnType,Arg0Type,Arg1Type) \
321
function(MethodName, \
322
boost::function< ReturnType ( const TypeId & , Arg0Type , Arg1Type )> \
323
(boost::bind(RefMethodId , _1, _2, _3 ))) \
324
325
326
// Declare metadata property for a class method (const) :
327
#define DR_CLASS_VOID_REFMETHOD2_CONST(MethodName,TypeId,RefMethodId,Arg0Type,Arg1Type) \
328
DR_CLASS_REFMETHOD2_CONST(MethodName,TypeId,RefMethodId,void,Arg0Type,Arg1Type) \
329
330
331
332
/***************************************
333
* Macros for methods with 3 arguments *
334
***************************************/
335
336
// Declare metadata property for a class method :
337
#define DR_CLASS_METHOD3(MethodName,TypeId,MethodId,ReturnType,Arg0Type,Arg1Type,Arg2Type) \
338
function(MethodName, \
339
boost::function< ReturnType ( TypeId & , Arg0Type , Arg1Type , Arg2Type )> \
340
(boost::bind(& MethodId , _1, _2, _3, _4))) \
341
342
343
// Declare metadata property for a class method :
344
#define DR_CLASS_VOID_METHOD3(MethodName,TypeId,MethodId,Arg0Type,Arg1Type,Arg2Type) \
345
DR_CLASS_METHOD3(MethodName,TypeId,MethodId,void,Arg0Type,Arg1Type,Arg2Type) \
346
347
348
// Declare metadata property for a class method (const) :
349
#define DR_CLASS_METHOD3_CONST(MethodName,TypeId,MethodId,ReturnType,Arg0Type,Arg1Type,Arg2Type) \
350
function(MethodName, \
351
boost::function< ReturnType ( const TypeId & , Arg0Type , Arg1Type , Arg2Type )> \
352
(boost::bind(& MethodId , _1, _2, _3, _4 ))) \
353
354
355
// Declare metadata property for a class method (const) :
356
#define DR_CLASS_VOID_METHOD3_CONST(MethodName,TypeId,RefMethodId,Arg0Type,Arg1Type,Arg2Type) \
357
DR_CLASS_METHOD3_CONST(MethodName,TypeId,RefMethodId,void,Arg0Type,Arg1Type,Arg2Type) \
358
359
360
// Declare metadata property for a class method :
361
#define DR_CLASS_REFMETHOD3(MethodName,TypeId,RefMethodId,ReturnType,Arg0Type,Arg1Type,Arg2Type) \
362
function(MethodName, \
363
boost::function< ReturnType ( TypeId & , Arg0Type , Arg1Type , Arg2Type )> \
364
(boost::bind(RefMethodId , _1, _2, _3, _4))) \
365
366
367
// Declare metadata property for a class method :
368
#define DR_CLASS_VOID_REFMETHOD3(MethodName,TypeId,RefMethodId,Arg0Type,Arg1Type,Arg2Type) \
369
DR_CLASS_REFMETHOD3(MethodName,TypeId,RefMethodId,void,Arg0Type,Arg1Type,Arg2Type) \
370
371
372
// Declare metadata property for a class method (const) :
373
#define DR_CLASS_REFMETHOD3_CONST(MethodName,TypeId,RefMethodId,ReturnType,Arg0Type,Arg1Type,Arg2Type) \
374
function(MethodName, \
375
boost::function< ReturnType ( const TypeId & , Arg0Type , Arg1Type , Arg2Type )> \
376
(boost::bind(RefMethodId , _1, _2, _3, _4 ))) \
377
378
379
// Declare metadata property for a class method (const) :
380
#define DR_CLASS_VOID_REFMETHOD3_CONST(MethodName,TypeId,RefMethodId,Arg0Type,Arg1Type,Arg2Type) \
381
DR_CLASS_REFMETHOD3_CONST(MethodName,TypeId,RefMethodId,void,Arg0Type,Arg1Type,Arg2Type) \
382
383
384
385
/***************************************
386
* Macros for methods with 4 arguments *
387
***************************************/
388
389
// Declare metadata property for a class method :
390
#define DR_CLASS_METHOD4(MethodName,TypeId,MethodId,ReturnType,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
391
function(MethodName, \
392
boost::function< ReturnType ( TypeId & , Arg0Type , Arg1Type , Arg2Type , Arg3Type )> \
393
(boost::bind(& MethodId , _1, _2, _3, _4, _5))) \
394
395
396
// Declare metadata property for a class method :
397
#define DR_CLASS_VOID_METHOD4(MethodName,TypeId,MethodId,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
398
DR_CLASS_METHOD4(MethodName,TypeId,MethodId,void,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
399
400
401
// Declare metadata property for a class method (const) :
402
#define DR_CLASS_METHOD4_CONST(MethodName,TypeId,MethodId,ReturnType,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
403
function(MethodName, \
404
boost::function< ReturnType ( const TypeId & , Arg0Type , Arg1Type , Arg2Type , Arg3Type )> \
405
(boost::bind(& MethodId , _1, _2, _3, _4, _5 ))) \
406
407
408
// Declare metadata property for a class method (const) :
409
#define DR_CLASS_VOID_METHOD4_CONST(MethodName,TypeId,MethodId,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
410
DR_CLASS_METHOD4_CONST(MethodName,TypeId,MethodId,void,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
411
412
413
// Declare metadata property for a class method :
414
#define DR_CLASS_REFMETHOD4(MethodName,TypeId,RefMethodId,ReturnType,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
415
function(MethodName, \
416
boost::function< ReturnType ( TypeId & , Arg0Type , Arg1Type , Arg2Type , Arg3Type )> \
417
(boost::bind(RefMethodId , _1, _2, _3, _4, _5))) \
418
419
420
// Declare metadata property for a class method :
421
#define DR_CLASS_VOID_REFMETHOD4(MethodName,TypeId,RefMethodId,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
422
DR_CLASS_REFMETHOD4(MethodName,TypeId,RefMethodId,void,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
423
424
425
// Declare metadata property for a class method (const) :
426
#define DR_CLASS_REFMETHOD4_CONST(MethodName,TypeId,RefMethodId,ReturnType,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
427
function(MethodName, \
428
boost::function< ReturnType ( const TypeId & , Arg0Type , Arg1Type , Arg2Type , Arg3Type )> \
429
(boost::bind(RefMethodId , _1, _2, _3, _4, _5 ))) \
430
431
432
// Declare metadata property for a class method (const) :
433
#define DR_CLASS_VOID_REFMETHOD4_CONST(MethodName,TypeId,RefMethodId,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
434
DR_CLASS_REFMETHOD4_CONST(MethodName,TypeId,RefMethodId,void,Arg0Type,Arg1Type,Arg2Type,Arg3Type) \
435
436
437
// Declare introspection metadata for an enum :
438
#define DR_ENUM_DECLARE2(TypeId,TypeName) \
439
::camp::Enum::declare< TypeId >(TypeName) \
440
441
442
// Declare introspection metadata for a enum :
443
#define DR_ENUM_DECLARE(TypeId) \
444
DR_ENUM_DECLARE2( TypeId , ::datatools::detail::reflection::guid< TypeId >() ) \
445
446
447
#endif // DATATOOLS_DETAIL_REFLECTION_MACROS_H
448
449
// Local Variables: --
450
// mode: c++ --
451
// c-file-style: "gnu" --
452
// tab-width: 2 --
453
// End: --
reflection_utils.h
Generated by
1.8.15