Medical Imaging Interaction Toolkit  2023.12.99-b826bd4b
Medical Imaging Interaction Toolkit
berryMacros.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef __BERRY_MACROS_H__
14 #define __BERRY_MACROS_H__
15 
16 #include "berryWeakPointer.h"
17 
18 #include "berryReflection.h"
19 #include "berryExtensionType.h"
20 
21 #define berryArgGlue(x, y) x y
22 #define berryArgCount(_1,_2,_3,_4,_5,_6,_7,_8,count,...) count
23 #define berryExpandArgs(args) berryArgCount args
24 #define berryCountArgsMax8(...) berryExpandArgs((__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0))
25 
26 #define berryOverloadMacro2(name, count) name##count
27 #define berryOverloadMacro1(name, count) berryOverloadMacro2(name, count)
28 #define berryOverloadMacro(name, count) berryOverloadMacro1(name, count)
29 #define berryCallOverload(name, ...) berryArgGlue(berryOverloadMacro(name, berryCountArgsMax8(__VA_ARGS__)), (__VA_ARGS__))
30 
31 #define berryObjectMacro(...) berryCallOverload(berryObjectMacro, __VA_ARGS__)
32 
33 #define berryObjectTypeInfo(...) \
34  static ::berry::Reflection::TypeInfo GetStaticTypeInfo() \
35  { return ::berry::Reflection::TypeInfo::New<Self>(); } \
36  ::berry::Reflection::TypeInfo GetTypeInfo() const override \
37  { return Self::GetStaticTypeInfo(); } \
38  /*typedef ::berry::Reflection::TypeList<__VA_ARGS__> SuperclassTypes;*/\
39  static QList< ::berry::Reflection::TypeInfo> GetStaticSuperclasses() \
40  { return ::berry::Reflection::GetSuperclasses<Self>(); } \
41  QList< ::berry::Reflection::TypeInfo> GetSuperclasses() const override \
42  { return Self::GetStaticSuperclasses(); }
43 
44 #define berryObjectMacro1(className) \
45  typedef className Self; \
46  typedef berry::SmartPointer<Self> Pointer; \
47  typedef berry::SmartPointer<const Self> ConstPointer; \
48  typedef berry::WeakPointer<Self> WeakPtr; \
49  typedef berry::WeakPointer<const Self> ConstWeakPtr; \
50  static const char* GetStaticClassName() \
51  { return #className; }
52 
53 #define berryObjectMacro2(className, super1) \
54  berryObjectMacro1(className) \
55  berryObjectTypeInfo(super1)
56 #define berryObjectMacro3(className, super1, super2) \
57  berryObjectMacro1(className) \
58  berryObjectTypeInfo(super1, super2)
59 #define berryObjectMacro4(className, super1, super2, super3) \
60  berryObjectMacro1(className) \
61  berryObjectTypeInfo(super1, super2, super3)
62 #define berryObjectMacro5(className, super1, super2, super3, super4) \
63  berryObjectMacro1(className) \
64  berryObjectTypeInfo(super1, super2, super3, super4)
65 #define berryObjectMacro6(className, super1, super2, super3, super4, super5) \
66  berryObjectMacro1(className) \
67  berryObjectTypeInfo(super1, super2, super3, super4, super5)
68 #define berryObjectMacro7(className, super1, super2, super3, super4, super5, super6) \
69  berryObjectMacro1(className) \
70  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6)
71 #define berryObjectMacro8(className, super1, super2, super3, super4, super5, super6, super7) \
72  berryObjectMacro1(className) \
73  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6, super7)
74 #define berryObjectMacro9(className, super1, super2, super3, super4, super5, super6, super7, super8) \
75  berryObjectMacro1(className) \
76  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6, super7, super8)
77 
78 #define BERRY_REGISTER_EXTENSION_CLASS(_ClassType, _PluginContext) \
79 { \
80  Q_UNUSED(_PluginContext) \
81  QString typeName = _ClassType::staticMetaObject.className(); \
82  ::berry::registerExtensionType<_ClassType>(typeName.toLatin1().data()); \
83 }
84 
85 #endif /*__BERRY_MACROS_H__*/
berryWeakPointer.h
berryReflection.h
berryExtensionType.h