Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkSmartPointerProperty.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 mitkSmartPointerProperty_h
14 #define mitkSmartPointerProperty_h
15 
16 #include "mitkBaseProperty.h"
17 #include "mitkUIDGenerator.h"
18 #include <MitkCoreExports.h>
19 
20 #include <list>
21 #include <map>
22 #include <string>
23 
24 namespace mitk
25 {
26 #ifdef _MSC_VER
27 #pragma warning(push)
28 #pragma warning(disable : 4522)
29 #endif
30 
31  //##Documentation
32  //## @brief Property containing a smart-pointer
33  //## @ingroup DataManagement
35  {
36  public:
38  itkFactorylessNewMacro(Self);
39  itkCloneMacro(Self);
41 
42  typedef itk::Object::Pointer ValueType;
43 
44  itk::Object::Pointer GetSmartPointer() const;
45  ValueType GetValue() const;
46 
47  void SetSmartPointer(itk::Object *);
48  void SetValue(const ValueType &);
49 
51  std::string GetValueAsString() const override;
52 
53  static void PostProcessXMLReading();
54 
56  static unsigned int GetReferenceCountFor(itk::Object *);
57  static std::string GetReferenceUIDFor(itk::Object *);
58  static void RegisterPointerTarget(itk::Object *, const std::string uid);
59 
60  using BaseProperty::operator=;
61 
62  protected:
63  SmartPointerProperty(itk::Object * = nullptr);
65 
66  itk::Object::Pointer m_SmartPointer;
67 
68  private:
69  // purposely not implemented
70  SmartPointerProperty &operator=(const SmartPointerProperty &);
71 
72  itk::LightObject::Pointer InternalClone() const override;
73 
74  bool IsEqual(const BaseProperty &) const override;
75  bool Assign(const BaseProperty &) override;
76 
77  typedef std::map<itk::Object *, unsigned int> ReferenceCountMapType;
78  typedef std::map<itk::Object *, std::string> ReferencesUIDMapType;
79  typedef std::map<SmartPointerProperty *, std::string> ReadInSmartPointersMapType;
80  typedef std::map<std::string, itk::Object *> ReadInTargetsMapType;
81 
83  static ReferenceCountMapType m_ReferenceCount;
84  static ReferencesUIDMapType m_ReferencesUID;
85  static ReadInSmartPointersMapType m_ReadInInstances;
86  static ReadInTargetsMapType m_ReadInTargets;
87 
89  static UIDGenerator m_UIDGenerator;
90  };
91 
92 #ifdef _MSC_VER
93 #pragma warning(pop)
94 #endif
95 
96 } // namespace mitk
97 
98 #endif
mitk::SmartPointerProperty::ValueType
itk::Object::Pointer ValueType
Definition: mitkSmartPointerProperty.h:40
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:35
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
mitk::SmartPointerProperty
Property containing a smart-pointer.
Definition: mitkSmartPointerProperty.h:34
mitkUIDGenerator.h
mitk::SmartPointerProperty::m_SmartPointer
itk::Object::Pointer m_SmartPointer
Definition: mitkSmartPointerProperty.h:66
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
MitkCoreExports.h
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::UIDGenerator
Generated unique IDs.
Definition: mitkUIDGenerator.h:31
mitkBaseProperty.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15