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

#include <mitkGenericProperty.h>

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

Public Types

typedef T ValueType
 

Public Member Functions

 mitkClassMacro (GenericProperty, BaseProperty)
 
 mitkNewMacro1Param (GenericProperty< T >, T)
 
Pointer Clone () const
 
virtual void SetValue (T _arg)
 
virtual T GetValue () const
 
std::string GetValueAsString () const override
 
bool ToJSON (nlohmann::json &) const override
 Serialize property value(s) to JSON. More...
 
bool FromJSON (const nlohmann::json &) override
 Deserialize property value(s) from JSON. More...
 
BasePropertyoperator= (const BaseProperty &property)
 Assigns property to this BaseProperty instance. More...
 
- Public Member Functions inherited from mitk::BaseProperty
 mitkClassMacroItkParent (BaseProperty, itk::Object)
 
Pointer Clone () const
 
bool operator== (const BaseProperty &property) const
 Subclasses must implement IsEqual(const BaseProperty&) to support comparison. More...
 
BasePropertyoperator= (const BaseProperty &property)
 Assigns property to this BaseProperty instance. More...
 
bool AssignProperty (const BaseProperty &property)
 Assigns property to this BaseProperty instance. More...
 

Protected Member Functions

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

Protected Attributes

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 if a property which can not be returned as string. More...
 

Detailed Description

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

@ brief Template class for generating properties for int, float, bool, etc.

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

  • an operator<< so that the properties 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 mess up serialization for example.

Definition at line 46 of file mitkGenericProperty.h.

Member Typedef Documentation

◆ ValueType

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

Definition at line 53 of file mitkGenericProperty.h.

Constructor & Destructor Documentation

◆ GenericProperty() [1/3]

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

Definition at line 78 of file mitkGenericProperty.h.

◆ GenericProperty() [2/3]

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

Definition at line 79 of file mitkGenericProperty.h.

◆ GenericProperty() [3/3]

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

Definition at line 80 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 j)
inlineoverridevirtual

Deserialize property value(s) from JSON.

Rely on exceptions for error handling when implementing deserialization.

Returns
False if not deserializable by design, true otherwise.

Implements mitk::BaseProperty.

Definition at line 70 of file mitkGenericProperty.h.

◆ GetValue()

◆ GetValueAsString()

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

Reimplemented from mitk::BaseProperty.

Definition at line 58 of file mitkGenericProperty.h.

◆ mitkClassMacro()

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

◆ mitkNewMacro1Param()

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

◆ operator=()

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

Assigns property to this BaseProperty instance.

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

◆ SetValue()

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

◆ ToJSON()

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

Serialize property value(s) to JSON.

Rely on exceptions for error handling when implementing serialization.

Returns
False if not serializable by design, true otherwise.

Implements mitk::BaseProperty.

Definition at line 65 of file mitkGenericProperty.h.

Member Data Documentation

◆ m_Value

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

Definition at line 81 of file mitkGenericProperty.h.


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