19 mitk::SmartPointerProperty::ReferenceCountMapType mitk::SmartPointerProperty::m_ReferenceCount;
20 mitk::SmartPointerProperty::ReferencesUIDMapType mitk::SmartPointerProperty::m_ReferencesUID;
21 mitk::SmartPointerProperty::ReadInSmartPointersMapType mitk::SmartPointerProperty::m_ReadInInstances;
22 mitk::SmartPointerProperty::ReadInTargetsMapType mitk::SmartPointerProperty::m_ReadInTargets;
27 for (
auto iter = m_ReadInInstances.begin(); iter != m_ReadInInstances.end(); ++iter)
29 if (m_ReadInTargets.find(iter->second) != m_ReadInTargets.end())
31 iter->first->SetSmartPointer(m_ReadInTargets[iter->second]);
35 m_ReadInInstances.clear();
41 if (m_ReferenceCount.find(
object) != m_ReferenceCount.end())
43 return m_ReferenceCount[object];
53 m_ReadInTargets[uid] = object;
58 if (m_ReferencesUID.find(
object) != m_ReferencesUID.end())
60 return m_ReferencesUID[object];
64 return std::string(
"invalid");
68 bool mitk::SmartPointerProperty::IsEqual(
const BaseProperty &property)
const
70 return this->m_SmartPointer ==
static_cast<const Self &
>(property).m_SmartPointer;
73 bool mitk::SmartPointerProperty::Assign(
const BaseProperty &property)
75 this->m_SmartPointer =
static_cast<const Self &
>(property).m_SmartPointer;
81 SetSmartPointer(pointer);
85 :
BaseProperty(other), m_SmartPointer(other.m_SmartPointer)
91 return m_SmartPointer;
96 return this->GetSmartPointer();
101 if (m_SmartPointer.GetPointer() != pointer)
104 if (m_SmartPointer.GetPointer() &&
105 --m_ReferenceCount[m_SmartPointer.GetPointer()] == 0)
107 m_ReferenceCount.erase(m_SmartPointer.GetPointer());
108 m_ReferencesUID.erase(m_SmartPointer.GetPointer());
111 if (pointer && ++m_ReferenceCount[pointer] == 1)
113 m_ReferencesUID[pointer] = m_UIDGenerator.GetUID();
117 m_SmartPointer = pointer;
124 this->SetSmartPointer(value.GetPointer());
129 if (m_SmartPointer.IsNotNull())
130 return m_ReferencesUID[m_SmartPointer.GetPointer()];
132 return std::string(
"NULL");
138 result->UnRegister();
static void PostProcessXMLReading()
itk::SmartPointer< Self > Pointer
itk::Object::Pointer ValueType
Property containing a smart-pointer.
virtual std::string GetValueAsString() const override
mainly for XML output
SmartPointerProperty(itk::Object *=nullptr)
itk::Object::Pointer GetSmartPointer() const
Abstract base class for properties.
ValueType GetValue() const
static std::string GetReferenceUIDFor(itk::Object *)
static void RegisterPointerTarget(itk::Object *, const std::string uid)
void SetValue(const ValueType &)
static unsigned int GetReferenceCountFor(itk::Object *)
Return the number of SmartPointerProperties that reference the object given as parameter.
void SetSmartPointer(itk::Object *)