Medical Imaging Interaction Toolkit  2024.06.99-2ddd1118
Medical Imaging Interaction Toolkit
mitkWeakPointerProperty.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 mitkWeakPointerProperty_h
14 #define mitkWeakPointerProperty_h
15 
16 #include "itkWeakPointer.h"
17 #include "mitkBaseProperty.h"
18 #include <MitkCoreExports.h>
19 
20 namespace mitk
21 {
22 #ifdef _MSC_VER
23 #pragma warning(push)
24 #pragma warning(disable : 4522)
25 #endif
26 
27  //##Documentation
28  //## @brief Property containing a smart-pointer
29  //##
30  //## @ingroup DataManagement
32  {
33  public:
35 
36  itkFactorylessNewMacro(Self);
37 
38  itkCloneMacro(Self);
40 
41  ~WeakPointerProperty() override;
42 
43  typedef itk::WeakPointer<itk::Object> ValueType;
44 
45  ValueType GetWeakPointer() const;
46  ValueType GetValue() const;
47 
48  void SetWeakPointer(itk::Object *pointer);
49  void SetValue(const ValueType &value);
50 
51  std::string GetValueAsString() const override;
52 
53  bool ToJSON(nlohmann::json& j) const override;
54  bool FromJSON(const nlohmann::json& j) override;
55 
56  using BaseProperty::operator=;
57 
58  protected:
59  itk::WeakPointer<itk::Object> m_WeakPointer;
60 
62 
63  WeakPointerProperty(itk::Object *pointer = nullptr);
64 
65  private:
66  // purposely not implemented
67  WeakPointerProperty &operator=(const WeakPointerProperty &);
68 
69  itk::LightObject::Pointer InternalClone() const override;
70 
71  bool IsEqual(const BaseProperty &property) const override;
72  bool Assign(const BaseProperty &property) override;
73  };
74 
75 #ifdef _MSC_VER
76 #pragma warning(pop)
77 #endif
78 
79 } // namespace mitk
80 
81 #endif
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
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
json
nlohmann::json json
Definition: mitkModelTestFixture.h:29
MitkCoreExports.h
mitk::WeakPointerProperty::ValueType
itk::WeakPointer< itk::Object > ValueType
Definition: mitkWeakPointerProperty.h:43
mitk::WeakPointerProperty
Property containing a smart-pointer.
Definition: mitkWeakPointerProperty.h:31
mitk::ToJSON
MITKCORE_EXPORT void ToJSON(nlohmann::json &j, AffineTransform3D::ConstPointer transform)
Write transform (4x4 matrix) as JSON array with 16 elements.
mitk::WeakPointerProperty::m_WeakPointer
itk::WeakPointer< itk::Object > m_WeakPointer
Definition: mitkWeakPointerProperty.h:59
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitkBaseProperty.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15