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