Medical Imaging Interaction Toolkit  2025.12.02
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 
42 
43  typedef itk::WeakPointer<itk::Object> ValueType;
44 
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
#define MITKCORE_EXPORT
Abstract base class for properties.
Property containing a smart-pointer.
itk::WeakPointer< itk::Object > ValueType
bool FromJSON(const nlohmann::json &j) override
Deserialize property value(s) from JSON.
void SetValue(const ValueType &value)
bool ToJSON(nlohmann::json &j) const override
Serialize property value(s) to JSON.
WeakPointerProperty(itk::Object *pointer=nullptr)
std::string GetValueAsString() const override
mitkNewMacro1Param(WeakPointerProperty, itk::Object *)
ValueType GetValue() const
ValueType GetWeakPointer() const
WeakPointerProperty(const WeakPointerProperty &)
mitkClassMacro(WeakPointerProperty, BaseProperty)
itk::WeakPointer< itk::Object > m_WeakPointer
void SetWeakPointer(itk::Object *pointer)
nlohmann::json json
Find image slices visible on a given plane.