Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkSerializerMacros.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 #include <itkObjectFactoryBase.h>
18 #include <itkVersion.h>
19 
20 #define MITK_REGISTER_SERIALIZER(classname) \
21  \
22 \
23 namespace mitk \
24  \
25 { \
26  \
27 class classname##Factory : public ::itk::ObjectFactoryBase \
28  \
29 { \
30  public: \
31  /* ITK typedefs */ \
32  typedef classname##Factory Self; \
33  typedef itk::ObjectFactoryBase Superclass; \
34  typedef itk::SmartPointer<Self> Pointer; \
35  typedef itk::SmartPointer<const Self> ConstPointer; \
36  \
37  /* Methods from ObjectFactoryBase */ \
38  virtual const char *GetITKSourceVersion() const override { return ITK_SOURCE_VERSION; } \
39  virtual const char *GetDescription() const override { return "Generated factory for " #classname; } \
40  /* Method for class instantiation. */ \
41  itkFactorylessNewMacro(Self); \
42  \
43  /* Run-time type information (and related methods). */ \
44  itkTypeMacro(classname##Factory, itkObjectFactoryBase); \
45  \
46  protected: \
47  classname##Factory() \
48  { \
49  itk::ObjectFactoryBase::RegisterOverride(#classname, \
50  #classname, \
51  "Generated factory for " #classname, \
52  1, \
53  itk::CreateObjectFunction<classname>::New()); \
54  } \
55  \
56  ~classname##Factory() {} \
57  private: \
58  classname##Factory(const Self &); /* purposely not implemented */ \
59  void operator=(const Self &); /* purposely not implemented */ \
60  \
61 }; \
62  \
63  class classname##RegistrationMethod \
64  { \
65  public: \
66  classname##RegistrationMethod() \
67  { \
68  m_Factory = classname##Factory::New(); \
69  itk::ObjectFactoryBase::RegisterFactory(m_Factory); \
70  } \
71  \
72  ~classname##RegistrationMethod() { itk::ObjectFactoryBase::UnRegisterFactory(m_Factory); } \
73  private: \
74  classname##Factory::Pointer m_Factory; \
75  }; \
76  \
77 } \
78  \
79 static mitk::classname##RegistrationMethod somestaticinitializer_##classname;