Medical Imaging Interaction Toolkit  2026.06.00
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 {
36  {
37  public:
39 
40  itkFactorylessNewMacro(Self);
41 
42  itkCloneMacro(Self);
44 
46 
48  typedef itk::WeakPointer<itk::Object> ValueType;
49 
55 
61 
67  void SetWeakPointer(itk::Object *pointer);
68 
74  void SetValue(const ValueType &value);
75 
80  std::string GetValueAsString() const override;
81 
88  bool ToJSON(nlohmann::json& j) const override;
89 
96  bool FromJSON(const nlohmann::json& j) override;
97 
98  using BaseProperty::operator=;
99 
100  protected:
101  itk::WeakPointer<itk::Object> m_WeakPointer;
102 
104 
105  WeakPointerProperty(itk::Object *pointer = nullptr);
106 
108 
109  private:
110  // purposely not implemented
111  WeakPointerProperty &operator=(const WeakPointerProperty &);
112 
113  bool IsEqual(const BaseProperty &property) const override;
114  bool Assign(const BaseProperty &property) override;
115  };
116 
117 
118 } // namespace mitk
119 
120 #endif
#define MITKCORE_EXPORT
Abstract base class for properties.
Property containing a weak (non-owning) pointer to an itk::Object.
itk::WeakPointer< itk::Object > ValueType
The type of the value stored by this property.
bool FromJSON(const nlohmann::json &j) override
JSON deserialization is not supported for WeakPointerProperty.
void SetValue(const ValueType &value)
Set the stored weak pointer (alias for SetWeakPointer()).
bool ToJSON(nlohmann::json &j) const override
JSON serialization is not supported for WeakPointerProperty.
WeakPointerProperty(itk::Object *pointer=nullptr)
std::string GetValueAsString() const override
Return the pointer address as a string.
mitkNewMacro1Param(WeakPointerProperty, itk::Object *)
ValueType GetValue() const
Get the stored weak pointer (alias for GetWeakPointer()).
ValueType GetWeakPointer() const
Get the stored weak pointer.
WeakPointerProperty(const WeakPointerProperty &)
mitkCloneMacro(WeakPointerProperty)
mitkClassMacro(WeakPointerProperty, BaseProperty)
itk::WeakPointer< itk::Object > m_WeakPointer
void SetWeakPointer(itk::Object *pointer)
Set the stored weak pointer.
nlohmann::json json
Find image slices visible on a given plane.