Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkCommon.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,
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 MITK_COMMON_H_DEFINED
18 #define MITK_COMMON_H_DEFINED
19 
20 #ifdef _MSC_VER
21 // This warns about truncation to 255 characters in debug/browse info
22 #pragma warning(disable : 4786)
23 #pragma warning(disable : 4068) /* disable unknown pragma warnings */
24 #endif
25 
26 // add only those headers here that are really necessary for all classes!
27 #include "itkObject.h"
28 #include "mitkConfig.h"
29 #include "mitkExceptionMacro.h"
30 #include "mitkGetClassHierarchy.h"
31 #include "mitkLogMacros.h"
32 
33 #ifndef MITK_UNMANGLE_IPPIC
34 #define mitkIpPicDescriptor mitkIpPicDescriptor
35 #endif
36 
37 typedef unsigned int MapperSlotId;
38 
44 #define mitkClassMacro(className, SuperClassName) \
45  typedef className Self; \
46  typedef SuperClassName Superclass; \
47  typedef itk::SmartPointer<Self> Pointer; \
48  typedef itk::SmartPointer<const Self> ConstPointer; \
49  static const char *GetStaticNameOfClass() { return #className; } \
50  virtual std::vector<std::string> GetClassHierarchy() const override { return mitk::GetClassHierarchy<Self>(); } \
51  itkTypeMacro(className, SuperClassName)
52 
53 #define mitkClassMacroItkParent(className, SuperClassName) \
54  typedef className Self; \
55  typedef SuperClassName Superclass; \
56  typedef itk::SmartPointer<Self> Pointer; \
57  typedef itk::SmartPointer<const Self> ConstPointer; \
58  static const char *GetStaticNameOfClass() { return #className; } \
59  virtual std::vector<std::string> GetClassHierarchy() const { return mitk::GetClassHierarchy<Self>(); } \
60  itkTypeMacro(className, SuperClassName)
61 
65 #define mitkClassMacroNoParent(className) \
66  typedef className Self; \
67  typedef itk::SmartPointer<Self> Pointer; \
68  typedef itk::SmartPointer<const Self> ConstPointer; \
69  static const char *GetStaticNameOfClass() { return #className; } \
70  virtual std::vector<std::string> GetClassHierarchy() const { return mitk::GetClassHierarchy<Self>(); } \
71  itkTypeMacroNoParent(className)
72 
76 #define mitkNewMacro1Param(classname, type) \
77  \
78  static Pointer New(type _arg) \
79  \
80  { \
81  Pointer smartPtr = new classname(_arg); \
82  smartPtr->UnRegister(); \
83  return smartPtr; \
84  }
85 
89 #define mitkNewMacro2Param(classname, typea, typeb) \
90  \
91  static Pointer New(typea _arga, typeb _argb) \
92  \
93  { \
94  Pointer smartPtr = new classname(_arga, _argb); \
95  smartPtr->UnRegister(); \
96  return smartPtr; \
97  }
98 
102 #define mitkNewMacro3Param(classname, typea, typeb, typec) \
103  \
104  static Pointer New(typea _arga, typeb _argb, typec _argc) \
105  \
106  { \
107  Pointer smartPtr = new classname(_arga, _argb, _argc); \
108  smartPtr->UnRegister(); \
109  return smartPtr; \
110  }
111 
115 #define mitkNewMacro4Param(classname, typea, typeb, typec, typed) \
116  \
117  static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd) \
118  \
119  { \
120  Pointer smartPtr = new classname(_arga, _argb, _argc, _argd); \
121  smartPtr->UnRegister(); \
122  return smartPtr; \
123  }
124 
128 #define mitkNewMacro5Param(classname, typea, typeb, typec, typed, typee) \
129  \
130  static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd, typee _arge) \
131  \
132  { \
133  Pointer smartPtr = new classname(_arga, _argb, _argc, _argd, _arge); \
134  smartPtr->UnRegister(); \
135  return smartPtr; \
136  }
137 
141 #define mitkNewMacro6Param(classname, typea, typeb, typec, typed, typee, typef) \
142  \
143  static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd, typee _arge, typef _argf) \
144  \
145  { \
146  Pointer smartPtr = new classname(_arga, _argb, _argc, _argd, _arge, _argf); \
147  smartPtr->UnRegister(); \
148  return smartPtr; \
149  }
150 
153 #define mitkGetObjectMacroConst(name, type) \
154  virtual type *Get##name() const \
155  { \
156  itkDebugMacro("returning " #name " address " << this->m_##name); \
157  return this->m_##name.GetPointer(); \
158  }
159 
162 #define mitkCloneMacro(classname) \
163  virtual itk::LightObject::Pointer InternalClone() const override \
164  \
165  { \
166  Pointer smartPtr = new classname(*this); \
167  smartPtr->UnRegister(); \
168  return smartPtr.GetPointer(); \
169  }
170 
175 #ifdef MITK_NO_DEPRECATED_WARNINGS
176 #define DEPRECATED(func) func
177 #elif defined(__GNUC__)
178 #define DEPRECATED(...) __VA_ARGS__ __attribute__((deprecated))
179 #elif defined(_MSC_VER)
180 #define DEPRECATED(...) __declspec(deprecated)##__VA_ARGS__
181 #else
182 #pragma message("WARNING: You need to implement DEPRECATED for your compiler!")
183 #define DEPRECATED(func) func
184 #endif
185 
190 #if defined(__clang__) || defined(__GNUC__)
191 #define MITK_EXPORT __attribute__((visibility("default")))
192 #define MITK_IMPORT __attribute__((visibility("default")))
193 #define MITK_LOCAL __attribute__((visibility("hidden")))
194 #elif defined(WIN32)
195 #define MITK_EXPORT __declspec(dllexport)
196 #define MITK_IMPORT __declspec(dllimport)
197 #define MITK_LOCAL
198 #else
199 #define MITK_EXPORT
200 #define MITK_IMPORT
201 #define MITK_LOCAL
202 #endif
203 
204 #endif // MITK_COMMON_H_DEFINED
unsigned int MapperSlotId
Definition: mitkCommon.h:37