Medical Imaging Interaction Toolkit  2023.12.00
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 class QStringList;
22 
23 #define berryArgGlue(x, y) x y
24 #define berryArgCount(_1,_2,_3,_4,_5,_6,_7,_8,count,...) count
25 #define berryExpandArgs(args) berryArgCount args
26 #define berryCountArgsMax8(...) berryExpandArgs((__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0))
27 
28 #define berryOverloadMacro2(name, count) name##count
29 #define berryOverloadMacro1(name, count) berryOverloadMacro2(name, count)
30 #define berryOverloadMacro(name, count) berryOverloadMacro1(name, count)
31 #define berryCallOverload(name, ...) berryArgGlue(berryOverloadMacro(name, berryCountArgsMax8(__VA_ARGS__)), (__VA_ARGS__))
32 
33 #define berryObjectMacro(...) berryCallOverload(berryObjectMacro, __VA_ARGS__)
34 
35 #define berryObjectTypeInfo(...) \
36  static ::berry::Reflection::TypeInfo GetStaticTypeInfo() \
37  { return ::berry::Reflection::TypeInfo::New<Self>(); } \
38  ::berry::Reflection::TypeInfo GetTypeInfo() const override \
39  { return Self::GetStaticTypeInfo(); } \
40  /*typedef ::berry::Reflection::TypeList<__VA_ARGS__> SuperclassTypes;*/\
41  static QList< ::berry::Reflection::TypeInfo> GetStaticSuperclasses() \
42  { return ::berry::Reflection::GetSuperclasses<Self>(); } \
43  QList< ::berry::Reflection::TypeInfo> GetSuperclasses() const override \
44  { return Self::GetStaticSuperclasses(); }
45 
46 #define berryObjectMacro1(className) \
47  typedef className Self; \
48  typedef berry::SmartPointer<Self> Pointer; \
49  typedef berry::SmartPointer<const Self> ConstPointer; \
50  typedef berry::WeakPointer<Self> WeakPtr; \
51  typedef berry::WeakPointer<const Self> ConstWeakPtr; \
52  static const char* GetStaticClassName() \
53  { return #className; }
54 
55 #define berryObjectMacro2(className, super1) \
56  berryObjectMacro1(className) \
57  berryObjectTypeInfo(super1)
58 #define berryObjectMacro3(className, super1, super2) \
59  berryObjectMacro1(className) \
60  berryObjectTypeInfo(super1, super2)
61 #define berryObjectMacro4(className, super1, super2, super3) \
62  berryObjectMacro1(className) \
63  berryObjectTypeInfo(super1, super2, super3)
64 #define berryObjectMacro5(className, super1, super2, super3, super4) \
65  berryObjectMacro1(className) \
66  berryObjectTypeInfo(super1, super2, super3, super4)
67 #define berryObjectMacro6(className, super1, super2, super3, super4, super5) \
68  berryObjectMacro1(className) \
69  berryObjectTypeInfo(super1, super2, super3, super4, super5)
70 #define berryObjectMacro7(className, super1, super2, super3, super4, super5, super6) \
71  berryObjectMacro1(className) \
72  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6)
73 #define berryObjectMacro8(className, super1, super2, super3, super4, super5, super6, super7) \
74  berryObjectMacro1(className) \
75  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6, super7)
76 #define berryObjectMacro9(className, super1, super2, super3, super4, super5, super6, super7, super8) \
77  berryObjectMacro1(className) \
78  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6, super7, super8)
79 
80 #define BERRY_REGISTER_EXTENSION_CLASS(_ClassType, _PluginContext) \
81 { \
82  Q_UNUSED(_PluginContext) \
83  QString typeName = _ClassType::staticMetaObject.className(); \
84  ::berry::registerExtensionType<_ClassType>(typeName.toLatin1().data()); \
85 }
86 
87 #endif /*__BERRY_MACROS_H__*/
berryWeakPointer.h
berryReflection.h
berryExtensionType.h