Medical Imaging Interaction Toolkit  2024.06.00
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 (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 mitkCommon_h
14 #define mitkCommon_h
15 
16 #ifdef _MSC_VER
17 // This warns about truncation to 255 characters in debug/browse info
18 #pragma warning(disable : 4786)
19 #pragma warning(disable : 4068) /* disable unknown pragma warnings */
20 #endif
21 
22 // add only those headers here that are really necessary for all classes!
23 #include "itkObject.h"
24 #include "mitkConfig.h"
25 #include "mitkExceptionMacro.h"
26 #include "mitkGetClassHierarchy.h"
27 #include "mitkLog.h"
28 
29 typedef unsigned int MapperSlotId;
30 
36 #define mitkClassMacro(className, SuperClassName) \
37  typedef className Self; \
38  typedef SuperClassName Superclass; \
39  typedef itk::SmartPointer<Self> Pointer; \
40  typedef itk::SmartPointer<const Self> ConstPointer; \
41  static const char *GetStaticNameOfClass() { return #className; } \
42  virtual std::vector<std::string> GetClassHierarchy() const override { return mitk::GetClassHierarchy<Self>(); } \
43  itkTypeMacro(className, SuperClassName);
44 
45 #define mitkClassMacroItkParent(className, SuperClassName) \
46  typedef className Self; \
47  typedef SuperClassName Superclass; \
48  typedef itk::SmartPointer<Self> Pointer; \
49  typedef itk::SmartPointer<const Self> ConstPointer; \
50  static const char *GetStaticNameOfClass() { return #className; } \
51  virtual std::vector<std::string> GetClassHierarchy() const { return mitk::GetClassHierarchy<Self>(); } \
52  itkTypeMacro(className, SuperClassName);
53 
57 #define mitkClassMacroNoParent(className) \
58  typedef className Self; \
59  typedef itk::SmartPointer<Self> Pointer; \
60  typedef itk::SmartPointer<const Self> ConstPointer; \
61  static const char *GetStaticNameOfClass() { return #className; } \
62  virtual std::vector<std::string> GetClassHierarchy() const { return mitk::GetClassHierarchy<Self>(); } \
63  itkTypeMacroNoParent(className)
64 
68 #define mitkNewMacro1Param(classname, type) \
69  \
70  static Pointer New(type _arg) \
71  \
72  { \
73  Pointer smartPtr = new classname(_arg); \
74  smartPtr->UnRegister(); \
75  return smartPtr; \
76  }
77 
81 #define mitkNewMacro2Param(classname, typea, typeb) \
82  \
83  static Pointer New(typea _arga, typeb _argb) \
84  \
85  { \
86  Pointer smartPtr = new classname(_arga, _argb); \
87  smartPtr->UnRegister(); \
88  return smartPtr; \
89  }
90 
94 #define mitkNewMacro3Param(classname, typea, typeb, typec) \
95  \
96  static Pointer New(typea _arga, typeb _argb, typec _argc) \
97  \
98  { \
99  Pointer smartPtr = new classname(_arga, _argb, _argc); \
100  smartPtr->UnRegister(); \
101  return smartPtr; \
102  }
103 
107 #define mitkNewMacro4Param(classname, typea, typeb, typec, typed) \
108  \
109  static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd) \
110  \
111  { \
112  Pointer smartPtr = new classname(_arga, _argb, _argc, _argd); \
113  smartPtr->UnRegister(); \
114  return smartPtr; \
115  }
116 
120 #define mitkNewMacro5Param(classname, typea, typeb, typec, typed, typee) \
121  \
122  static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd, typee _arge) \
123  \
124  { \
125  Pointer smartPtr = new classname(_arga, _argb, _argc, _argd, _arge); \
126  smartPtr->UnRegister(); \
127  return smartPtr; \
128  }
129 
133 #define mitkNewMacro6Param(classname, typea, typeb, typec, typed, typee, typef) \
134  \
135  static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd, typee _arge, typef _argf) \
136  \
137  { \
138  Pointer smartPtr = new classname(_arga, _argb, _argc, _argd, _arge, _argf); \
139  smartPtr->UnRegister(); \
140  return smartPtr; \
141  }
142 
145 #define mitkGetObjectMacroConst(name, type) \
146  virtual type *Get##name() const \
147  { \
148  itkDebugMacro("returning " #name " address " << this->m_##name); \
149  return this->m_##name.GetPointer(); \
150  }
151 
154 #define mitkCloneMacro(classname) \
155  virtual itk::LightObject::Pointer InternalClone() const override \
156  \
157  { \
158  Pointer smartPtr = new classname(*this); \
159  smartPtr->UnRegister(); \
160  return smartPtr.GetPointer(); \
161  }
162 
167 #ifdef MITK_NO_DEPRECATED_WARNINGS
168 #define DEPRECATED(func) func
169 #elif defined(__GNUC__)
170 #define DEPRECATED(...) __VA_ARGS__ __attribute__((deprecated))
171 #elif defined(_MSC_VER)
172 #define DEPRECATED(...) __declspec(deprecated)##__VA_ARGS__
173 #else
174 #pragma message("WARNING: You need to implement DEPRECATED for your compiler!")
175 #define DEPRECATED(func) func
176 #endif
177 
182 #if defined(__clang__) || defined(__GNUC__)
183 #define MITK_EXPORT __attribute__((visibility("default")))
184 #define MITK_IMPORT __attribute__((visibility("default")))
185 #define MITK_LOCAL __attribute__((visibility("hidden")))
186 #elif defined(WIN32)
187 #define MITK_EXPORT __declspec(dllexport)
188 #define MITK_IMPORT __declspec(dllimport)
189 #define MITK_LOCAL
190 #else
191 #define MITK_EXPORT
192 #define MITK_IMPORT
193 #define MITK_LOCAL
194 #endif
195 
196 #endif
mitkGetClassHierarchy.h
mitkExceptionMacro.h
mitkConfig.h
mitkLog.h
MapperSlotId
unsigned int MapperSlotId
Definition: mitkCommon.h:29