Medical Imaging Interaction Toolkit  2024.06.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  bool ToJSON(nlohmann::json& j) const override;
61  bool FromJSON(const nlohmann::json& j) override;
62 
63  using BaseProperty::operator=;
64 
65  protected:
66  SmartPointerProperty(itk::Object * = nullptr);
68 
69  itk::Object::Pointer m_SmartPointer;
70 
71  private:
72  // purposely not implemented
73  SmartPointerProperty &operator=(const SmartPointerProperty &);
74 
75  itk::LightObject::Pointer InternalClone() const override;
76 
77  bool IsEqual(const BaseProperty &) const override;
78  bool Assign(const BaseProperty &) override;
79 
80  typedef std::map<itk::Object *, unsigned int> ReferenceCountMapType;
81  typedef std::map<itk::Object *, std::string> ReferencesUIDMapType;
82  typedef std::map<SmartPointerProperty *, std::string> ReadInSmartPointersMapType;
83  typedef std::map<std::string, itk::Object *> ReadInTargetsMapType;
84 
86  static ReferenceCountMapType m_ReferenceCount;
87  static ReferencesUIDMapType m_ReferencesUID;
88  static ReadInSmartPointersMapType m_ReadInInstances;
89  static ReadInTargetsMapType m_ReadInTargets;
90 
92  static UIDGenerator m_UIDGenerator;
93  };
94 
95 #ifdef _MSC_VER
96 #pragma warning(pop)
97 #endif
98 
99 } // namespace mitk
100 
101 #endif
mitk::SmartPointerProperty::ValueType
itk::Object::Pointer ValueType
Definition: mitkSmartPointerProperty.h:40
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:36
mitk::FromJSON
MITKCORE_EXPORT void FromJSON(const nlohmann::json &j, AffineTransform3D::Pointer transform)
Read transform from JSON array (16 elements, resp. 4x4 matrix).
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:69
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
json
nlohmann::json json
Definition: mitkModelTestFixture.h:29
MitkCoreExports.h
mitk::ToJSON
MITKCORE_EXPORT void ToJSON(nlohmann::json &j, AffineTransform3D::ConstPointer transform)
Write transform (4x4 matrix) as JSON array with 16 elements.
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