Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::GenericProperty< T > Class Template Reference

Template class for generating properties for simple value types (int, float, bool, etc.). More...

#include <mitkGenericProperty.h>

Inheritance diagram for mitk::GenericProperty< T >:
Collaboration diagram for mitk::GenericProperty< T >:

Public Types

typedef T ValueType
 The type of the value stored by this property. More...
 

Public Member Functions

 mitkClassMacro (GenericProperty, BaseProperty)
 
 mitkNewMacro1Param (GenericProperty< T >, T)
 
Pointer Clone () const
 
virtual void SetValue (T _arg)
 Set the property value. More...
 
virtual T GetValue () const
 Get the property value. More...
 
std::string GetValueAsString () const override
 Return the property value as a string. More...
 
bool ToJSON (nlohmann::json &) const override
 Serialize property value to JSON. More...
 
bool FromJSON (const nlohmann::json &) override
 Deserialize property value from JSON. More...
 
BaseProperty & operator= (const BaseProperty &property)
 Assign a property value to this instance. More...
 
- Public Member Functions inherited from mitk::BaseProperty
 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...
 

Protected Member Functions

 GenericProperty ()
 
 GenericProperty (T x)
 
 GenericProperty (const GenericProperty &other)
 
 mitkCloneMacro (Self)
 
- Protected Member Functions inherited from mitk::BaseProperty
 BaseProperty ()
 
 BaseProperty (const BaseProperty &other)
 
 ~BaseProperty () override
 

Protected Attributes

T m_Value
 

Additional Inherited Members

- Static Public Attributes inherited from mitk::BaseProperty
static const std::string VALUE_CANNOT_BE_CONVERTED_TO_STRING
 Default return value for properties that cannot be converted to a string. More...
 

Detailed Description

template<typename T>
class mitk::GenericProperty< T >

Template class for generating properties for simple value types (int, float, bool, etc.).

This class template can be instantiated for all classes/internal types that fulfill these requirements:

  • an operator<< so that the property value can be put into a std::stringstream
  • an operator== so that two properties can be checked for equality
Note
You must use the macros mitkDeclareGenericProperty and mitkDefineGenericProperty to provide specializations for concrete types (e.g. BoolProperty). See mitkProperties.h for examples. If you don't use these macros, GetNameOfClass() will return "GenericProperty", which will break serialization.
Template Parameters
TThe value type stored by this property.
See also
BaseProperty
mitkDeclareGenericProperty
mitkDefineGenericProperty

Definition at line 46 of file mitkGenericProperty.h.

Member Typedef Documentation

◆ ValueType

template<typename T >
typedef T mitk::GenericProperty< T >::ValueType

The type of the value stored by this property.

Definition at line 54 of file mitkGenericProperty.h.

Constructor & Destructor Documentation

◆ GenericProperty() [1/3]

template<typename T >
mitk::GenericProperty< T >::GenericProperty ( )
inlineprotected

Definition at line 109 of file mitkGenericProperty.h.

◆ GenericProperty() [2/3]

template<typename T >
mitk::GenericProperty< T >::GenericProperty ( T  x)
inlineprotected

Definition at line 110 of file mitkGenericProperty.h.

◆ GenericProperty() [3/3]

template<typename T >
mitk::GenericProperty< T >::GenericProperty ( const GenericProperty< T > &  other)
inlineprotected

Definition at line 111 of file mitkGenericProperty.h.

Member Function Documentation

◆ Clone()

template<typename T >
Pointer mitk::GenericProperty< T >::Clone ( ) const

◆ FromJSON()

template<typename T >
bool mitk::GenericProperty< T >::FromJSON ( const nlohmann::json &  )
inlineoverridevirtual

Deserialize property value from JSON.

The base GenericProperty template does not support JSON deserialization. Concrete specializations (via mitkDefineGenericProperty) override this to provide actual deserialization.

Returns
Always false in the base template.

Implements mitk::BaseProperty.

Definition at line 101 of file mitkGenericProperty.h.

◆ GetValue()

template<typename T >
virtual T mitk::GenericProperty< T >::GetValue ( ) const
virtual

◆ GetValueAsString()

template<typename T >
std::string mitk::GenericProperty< T >::GetValueAsString ( ) const
inlineoverridevirtual

Return the property value as a string.

Uses operator<< to stream the value into a stringstream.

Returns
A string representation of the property value.

Reimplemented from mitk::BaseProperty.

Definition at line 71 of file mitkGenericProperty.h.

◆ mitkClassMacro()

template<typename T >
mitk::GenericProperty< T >::mitkClassMacro ( GenericProperty< T >  ,
BaseProperty   
)

◆ mitkCloneMacro()

template<typename T >
mitk::GenericProperty< T >::mitkCloneMacro ( Self  )
protected

◆ mitkNewMacro1Param()

template<typename T >
mitk::GenericProperty< T >::mitkNewMacro1Param ( GenericProperty< T >  ,
T   
)

◆ operator=()

template<typename T >
BaseProperty& mitk::BaseProperty::operator=

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

◆ SetValue()

template<typename T >
virtual void mitk::GenericProperty< T >::SetValue ( T  _arg)
virtual

Set the property value.

Parameters
[in]_argThe new value.

◆ ToJSON()

template<typename T >
bool mitk::GenericProperty< T >::ToJSON ( nlohmann::json &  ) const
inlineoverridevirtual

Serialize property value to JSON.

The base GenericProperty template does not support JSON serialization. Concrete specializations (via mitkDefineGenericProperty) override this to provide actual serialization.

Returns
Always false in the base template.

Implements mitk::BaseProperty.

Definition at line 87 of file mitkGenericProperty.h.

Member Data Documentation

◆ m_Value

template<typename T >
T mitk::GenericProperty< T >::m_Value
protected

Definition at line 112 of file mitkGenericProperty.h.


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