Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryMacros.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __BERRY_MACROS_H__
18 #define __BERRY_MACROS_H__
19 
20 #include "berryWeakPointer.h"
21 
22 #include "berryReflection.h"
23 #include "berryExtensionType.h"
24 
25 class QStringList;
26 
27 #define berryArgGlue(x, y) x y
28 #define berryArgCount(_1,_2,_3,_4,_5,_6,_7,_8,count,...) count
29 #define berryExpandArgs(args) berryArgCount args
30 #define berryCountArgsMax8(...) berryExpandArgs((__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0))
31 
32 #define berryOverloadMacro2(name, count) name##count
33 #define berryOverloadMacro1(name, count) berryOverloadMacro2(name, count)
34 #define berryOverloadMacro(name, count) berryOverloadMacro1(name, count)
35 #define berryCallOverload(name, ...) berryArgGlue(berryOverloadMacro(name, berryCountArgsMax8(__VA_ARGS__)), (__VA_ARGS__))
36 
37 #define berryObjectMacro(...) berryCallOverload(berryObjectMacro, __VA_ARGS__)
38 
39 #define berryObjectTypeInfo(...) \
40  static ::berry::Reflection::TypeInfo GetStaticTypeInfo() \
41  { return ::berry::Reflection::TypeInfo::New<Self>(); } \
42  ::berry::Reflection::TypeInfo GetTypeInfo() const override \
43  { return Self::GetStaticTypeInfo(); } \
44  typedef ::berry::Reflection::TypeList<__VA_ARGS__> SuperclassTypes; \
45  static QList< ::berry::Reflection::TypeInfo> GetStaticSuperclasses() \
46  { return ::berry::Reflection::GetSuperclasses<Self>(); } \
47  QList< ::berry::Reflection::TypeInfo> GetSuperclasses() const override \
48  { return Self::GetStaticSuperclasses(); }
49 
50 #define berryObjectMacro1(className) \
51  typedef className Self; \
52  typedef berry::SmartPointer<Self> Pointer; \
53  typedef berry::SmartPointer<const Self> ConstPointer; \
54  typedef berry::WeakPointer<Self> WeakPtr; \
55  typedef berry::WeakPointer<const Self> ConstWeakPtr; \
56  static const char* GetStaticClassName() \
57  { return #className; }
58 
59 #define berryObjectMacro2(className, super1) \
60  berryObjectMacro1(className) \
61  berryObjectTypeInfo(super1)
62 #define berryObjectMacro3(className, super1, super2) \
63  berryObjectMacro1(className) \
64  berryObjectTypeInfo(super1, super2)
65 #define berryObjectMacro4(className, super1, super2, super3) \
66  berryObjectMacro1(className) \
67  berryObjectTypeInfo(super1, super2, super3)
68 #define berryObjectMacro5(className, super1, super2, super3, super4) \
69  berryObjectMacro1(className) \
70  berryObjectTypeInfo(super1, super2, super3, super4)
71 #define berryObjectMacro6(className, super1, super2, super3, super4, super5) \
72  berryObjectMacro1(className) \
73  berryObjectTypeInfo(super1, super2, super3, super4, super5)
74 #define berryObjectMacro7(className, super1, super2, super3, super4, super5, super6) \
75  berryObjectMacro1(className) \
76  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6)
77 #define berryObjectMacro8(className, super1, super2, super3, super4, super5, super6, super7) \
78  berryObjectMacro1(className) \
79  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6, super7)
80 #define berryObjectMacro9(className, super1, super2, super3, super4, super5, super6, super7, super8) \
81  berryObjectMacro1(className) \
82  berryObjectTypeInfo(super1, super2, super3, super4, super5, super6, super7, super8)
83 
84 #define BERRY_REGISTER_EXTENSION_CLASS(_ClassType, _PluginContext) \
85 { \
86  Q_UNUSED(_PluginContext) \
87  QString typeName = _ClassType::staticMetaObject.className(); \
88  ::berry::registerExtensionType<_ClassType>(typeName.toLatin1().data()); \
89 }
90 
91 #endif /*__BERRY_MACROS_H__*/