Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::BaseProperty Class Referenceabstract

Abstract base class for properties. More...

#include <mitkBaseProperty.h>

Inheritance diagram for mitk::BaseProperty:
Collaboration diagram for mitk::BaseProperty:

Public Member Functions

 mitkClassMacroItkParent (BaseProperty, itk::Object)
 
Pointer Clone () const
 
bool operator== (const BaseProperty &property) const
 Compare two properties for equality. More...
 
BaseProperty & operator= (const BaseProperty &property)
 Assign a property value to this instance. More...
 
bool AssignProperty (const BaseProperty &property)
 Assign a property value to this instance and report success. More...
 
virtual std::string GetValueAsString () const
 Return the property value as a human-readable string. More...
 
virtual bool ToJSON (nlohmann::json &j) const =0
 Serialize property value(s) to JSON. More...
 
virtual bool FromJSON (const nlohmann::json &j)=0
 Deserialize property value(s) from JSON. More...
 

Static Public Attributes

static const std::string VALUE_CANNOT_BE_CONVERTED_TO_STRING
 Default return value for properties that cannot be converted to a string. More...
 

Protected Member Functions

 BaseProperty ()
 
 BaseProperty (const BaseProperty &other)
 
 ~BaseProperty () override
 

Detailed Description

Abstract base class for properties.

Base class for all properties in MITK. Properties represent arbitrary additional information that can be added to a PropertyList and associated with data objects. To define a new type of property, create a subclass of BaseProperty.

Concrete subclasses should define Set-/Get-methods to access the property value, which should be stored by value (not by reference). Subclasses must implement the pure virtual methods IsEqual() and Assign() for comparison and assignment support.

See also
PropertyList
GenericProperty
StringProperty

Definition at line 39 of file mitkBaseProperty.h.

Constructor & Destructor Documentation

◆ BaseProperty() [1/2]

mitk::BaseProperty::BaseProperty ( )
protected

◆ BaseProperty() [2/2]

mitk::BaseProperty::BaseProperty ( const BaseProperty &  other)
protected

◆ ~BaseProperty()

mitk::BaseProperty::~BaseProperty ( )
overrideprotected

Member Function Documentation

◆ AssignProperty()

bool mitk::BaseProperty::AssignProperty ( const BaseProperty &  property)

Assign a property value to this instance and report success.

This method is identical to the assignment operator, except for the return type. It allows callers to directly check whether the assignment was successful. The assignment fails if the source and target properties have different types. On success, the property is marked as modified.

Parameters
[in]propertyThe property whose value should be assigned to this instance.
Returns
true if the assignment was successful (same type), false otherwise.
See also
operator=

◆ Clone()

Pointer mitk::BaseProperty::Clone ( ) const

◆ FromJSON()

virtual bool mitk::BaseProperty::FromJSON ( const nlohmann::json &  j)
pure virtual

Deserialize property value(s) from JSON.

Subclasses must implement this method to restore their value from the provided JSON object. Rely on exceptions for error handling when implementing deserialization.

Parameters
[in]jThe JSON object containing the serialized value.
Returns
false if the property is not deserializable by design, true otherwise.

Implemented in mitk::IsoDoseLevelVectorProperty, mitk::IsoDoseLevelSetProperty, mitk::WeakPointerProperty, mitk::VectorProperty< DATATYPE >, mitk::TransferFunctionProperty, mitk::TemporoSpatialStringProperty, mitk::StringProperty, mitk::SmartPointerProperty, mitk::LookupTableProperty, mitk::LevelWindowProperty, mitk::GroupTagProperty, mitk::EnumerationProperty, mitk::ColorProperty, mitk::ClippingProperty, mitk::AnnotationProperty, mitk::GenericProperty< T >, mitk::GenericProperty< double >, mitk::GenericProperty< float >, and mitk::GenericProperty< int >.

◆ GetValueAsString()

virtual std::string mitk::BaseProperty::GetValueAsString ( ) const
virtual

Return the property value as a human-readable string.

The default implementation returns VALUE_CANNOT_BE_CONVERTED_TO_STRING. Subclasses should override this method to provide a meaningful string representation of their value.

Returns
A string representation of the property value.

Reimplemented in mitk::IsoDoseLevelVectorProperty, mitk::IsoDoseLevelSetProperty, mitk::WeakPointerProperty, mitk::VectorProperty< DATATYPE >, mitk::TransferFunctionProperty, mitk::TemporoSpatialStringProperty, mitk::StringProperty, mitk::SmartPointerProperty, mitk::LookupTableProperty, mitk::LevelWindowProperty, mitk::GenericProperty< T >, mitk::GenericProperty< double >, mitk::GenericProperty< float >, mitk::GenericProperty< int >, mitk::EnumerationProperty, mitk::ColorProperty, mitk::ClippingProperty, and mitk::AnnotationProperty.

◆ mitkClassMacroItkParent()

mitk::BaseProperty::mitkClassMacroItkParent ( BaseProperty  ,
itk::Object   
)

◆ operator=()

BaseProperty& mitk::BaseProperty::operator= ( const BaseProperty &  property)

Assign a property value to this instance.

Performs a polymorphic assignment from the given property. The assignment succeeds only if the source and target properties are of the same type. The subclass-specific Assign() method is called to perform the actual value copy.

Subclasses must implement Assign(const BaseProperty&) and call the superclass Assign method for proper handling. The copy assignment operator of the subclass should be disabled and the base class operator should be made visible using "using" statements.

Parameters
[in]propertyThe property whose value should be assigned to this instance.
Returns
A reference to this property.
See also
AssignProperty
Assign

◆ operator==()

bool mitk::BaseProperty::operator== ( const BaseProperty &  property) const

Compare two properties for equality.

Checks whether this property is equal to the given property. Two properties are considered equal if they have the same type (checked via typeid) and their subclass-specific IsEqual() method returns true.

Parameters
[in]propertyThe property to compare against.
Returns
true if both properties are of the same type and have equal values, false otherwise.
See also
IsEqual

◆ ToJSON()

virtual bool mitk::BaseProperty::ToJSON ( nlohmann::json &  j) const
pure virtual

Serialize property value(s) to JSON.

Subclasses must implement this method to serialize their value into the provided JSON object. Rely on exceptions for error handling when implementing serialization.

Parameters
[out]jThe JSON object to write the serialized value into.
Returns
false if the property is not serializable by design, true otherwise.

Implemented in mitk::IsoDoseLevelVectorProperty, mitk::IsoDoseLevelSetProperty, mitk::WeakPointerProperty, mitk::VectorProperty< DATATYPE >, mitk::TransferFunctionProperty, mitk::TemporoSpatialStringProperty, mitk::StringProperty, mitk::SmartPointerProperty, mitk::LookupTableProperty, mitk::LevelWindowProperty, mitk::GroupTagProperty, mitk::EnumerationProperty, mitk::ColorProperty, mitk::ClippingProperty, mitk::AnnotationProperty, mitk::GenericProperty< T >, mitk::GenericProperty< double >, mitk::GenericProperty< float >, and mitk::GenericProperty< int >.

Member Data Documentation

◆ VALUE_CANNOT_BE_CONVERTED_TO_STRING

const std::string mitk::BaseProperty::VALUE_CANNOT_BE_CONVERTED_TO_STRING
static

Default return value for properties that cannot be converted to a string.

This constant (value "n/a") is returned by GetValueAsString() in the base implementation to indicate that no string conversion is available.

Definition at line 136 of file mitkBaseProperty.h.


The documentation for this class was generated from the following file: