Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::PropertyList Class Reference

Key-value list holding instances of BaseProperty. More...

#include <mitkPropertyList.h>

Inheritance diagram for mitk::PropertyList:
Collaboration diagram for mitk::PropertyList:

Public Types

typedef std::map< std::string, BaseProperty::Pointer > PropertyMap
 
typedef std::pair< std::string, BaseProperty::Pointer > PropertyMapElementType
 

Public Member Functions

 mitkClassMacroItkParent (PropertyList, itk::Object)
 
Pointer Clone () const
 
BaseProperty::ConstPointer GetConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const override
 Retrieve a property by key (const version). More...
 
std::vector< std::string > GetPropertyKeys (const std::string &contextName="", bool includeDefaultContext=false) const override
 Retrieve all property keys. More...
 
std::vector< std::string > GetPropertyContextNames () const override
 Return available property context names. More...
 
BaseProperty * GetNonConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) override
 Retrieve a property by key (non-const version). More...
 
void SetProperty (const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Set a property in the list, preserving existing property type. More...
 
void RemoveProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Remove a property from the list by key. More...
 
mitk::BaseProperty * GetProperty (const std::string &propertyKey) const
 Get a property by its name. More...
 
void ReplaceProperty (const std::string &propertyKey, BaseProperty *property)
 Replace a property object in the list by a new one. More...
 
void ConcatenatePropertyList (PropertyList *pList, bool replace=false)
 Merge another PropertyList into this one. More...
 
template<typename T >
bool GetPropertyValue (const char *propertyKey, T &value) const
 Convenience access method for GenericProperty<T> properties. More...
 
bool GetBoolProperty (const char *propertyKey, bool &boolValue) const
 Convenience method to access the value of a BoolProperty. More...
 
bool Get (const char *propertyKey, bool &boolValue) const
 Shortcut for GetBoolProperty(). More...
 
void SetBoolProperty (const char *propertyKey, bool boolValue)
 Convenience method to set the value of a BoolProperty. More...
 
void Set (const char *propertyKey, bool boolValue)
 Shortcut for SetBoolProperty(). More...
 
bool GetIntProperty (const char *propertyKey, int &intValue) const
 Convenience method to access the value of an IntProperty. More...
 
bool Get (const char *propertyKey, int &intValue) const
 Shortcut for GetIntProperty(). More...
 
void SetIntProperty (const char *propertyKey, int intValue)
 Convenience method to set the value of an IntProperty. More...
 
void Set (const char *propertyKey, int intValue)
 Shortcut for SetIntProperty(). More...
 
bool GetFloatProperty (const char *propertyKey, float &floatValue) const
 Convenience method to access the value of a FloatProperty. More...
 
bool Get (const char *propertyKey, float &floatValue) const
 Shortcut for GetFloatProperty(). More...
 
void SetFloatProperty (const char *propertyKey, float floatValue)
 Convenience method to set the value of a FloatProperty. More...
 
void Set (const char *propertyKey, float floatValue)
 Shortcut for SetFloatProperty(). More...
 
bool GetDoubleProperty (const char *propertyKey, double &doubleValue) const
 Convenience method to access the value of a DoubleProperty. More...
 
bool Get (const char *propertyKey, double &doubleValue) const
 Shortcut for GetDoubleProperty(). More...
 
void SetDoubleProperty (const char *propertyKey, double doubleValue)
 Convenience method to set the value of a DoubleProperty. More...
 
void Set (const char *propertyKey, double doubleValue)
 Shortcut for SetDoubleProperty(). More...
 
bool GetStringProperty (const char *propertyKey, std::string &stringValue) const
 Convenience method to access the value of a StringProperty. More...
 
bool Get (const char *propertyKey, std::string &stringValue) const
 Shortcut for GetStringProperty(). More...
 
void SetStringProperty (const char *propertyKey, const char *stringValue)
 Convenience method to set the value of a StringProperty. More...
 
void Set (const char *propertyKey, const char *stringValue)
 Shortcut for SetStringProperty() accepting a C-string. More...
 
void Set (const char *propertyKey, const std::string &stringValue)
 Shortcut for SetStringProperty() accepting a std::string. More...
 
itk::ModifiedTimeType GetMTime () const override
 Get the modification timestamp of the list. More...
 
bool DeleteProperty (const std::string &propertyKey)
 Remove a property from the list/map by key. More...
 
const PropertyMap * GetMap () const
 Get a read-only pointer to the internal property map. More...
 
bool IsEmpty () const
 Check whether the property list contains no properties. More...
 
virtual void Clear ()
 Remove all properties from the list. More...
 
void ToJSON (nlohmann::json &j) const
 Serialize the property list to JSON. More...
 
void FromJSON (const nlohmann::json &j)
 Deserialize the property list from JSON. More...
 
- Public Member Functions inherited from mitk::IPropertyOwner
 ~IPropertyOwner () override
 
virtual bool PropertyIsOwned (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const
 Checks if a certain property exists. More...
 
- Public Member Functions inherited from mitk::IPropertyProvider
virtual ~IPropertyProvider ()
 Virtual destructor. More...
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 PropertyList ()
 
 PropertyList (const Self &other)
 
 ~PropertyList () override
 
 mitkCloneMacro (Self)
 

Protected Attributes

PropertyMap m_Properties
 Map of properties. More...
 

Detailed Description

Key-value list holding instances of BaseProperty.

This list is meant to hold an arbitrary list of "properties", which should describe the object associated with this list.

Usually you will use PropertyList as part of a DataNode object - in this context the properties describe the data object held by the DataNode (e.g. whether the object is rendered at all, which color is used for rendering, what name should be displayed for the object, etc.)

The values in the list are not fixed, you may introduce any kind of property that seems useful - all you have to do is inherit from BaseProperty.

The list is organized as a key-value pairs, i.e.

  • "name" : pointer to a StringProperty
  • "visible" : pointer to a BoolProperty
  • "color" : pointer to a ColorProperty
  • "volume" : pointer to a FloatProperty

Please see the documentation of SetProperty and ReplaceProperty for two quite different semantics. Normally SetProperty is what you want - this method will try to change the value of an existing property and will not allow you to replace e.g. a ColorProperty with an IntProperty.

Please also regard, that the key of a property must be a none empty string. This is a precondition. Setting properties with empty keys will raise an exception.

Definition at line 54 of file mitkPropertyList.h.

Member Typedef Documentation

◆ PropertyMap

typedef std::map<std::string, BaseProperty::Pointer> mitk::PropertyList::PropertyMap

Map structure to hold the properties: the map key is a string, the value consists of the actual property object (BaseProperty).

Definition at line 69 of file mitkPropertyList.h.

◆ PropertyMapElementType

typedef std::pair<std::string, BaseProperty::Pointer> mitk::PropertyList::PropertyMapElementType

Definition at line 70 of file mitkPropertyList.h.

Constructor & Destructor Documentation

◆ PropertyList() [1/2]

mitk::PropertyList::PropertyList ( )
protected

◆ PropertyList() [2/2]

mitk::PropertyList::PropertyList ( const Self &  other)
protected

◆ ~PropertyList()

mitk::PropertyList::~PropertyList ( )
overrideprotected

Member Function Documentation

◆ Clear()

virtual void mitk::PropertyList::Clear ( )
virtual

Remove all properties from the list.

◆ Clone()

Pointer mitk::PropertyList::Clone ( ) const

◆ ConcatenatePropertyList()

void mitk::PropertyList::ConcatenatePropertyList ( PropertyList *  pList,
bool  replace = false 
)

Merge another PropertyList into this one.

All properties from the given list are added to this list. If a property key already exists, the behavior depends on the replace flag.

Parameters
[in]pListThe property list to merge. If nullptr, the call is ignored.
[in]replaceIf true, existing properties are replaced via ReplaceProperty(). If false (default), existing properties are updated via SetProperty() (type-safe assignment).
See also
SetProperty
ReplaceProperty

◆ DeleteProperty()

bool mitk::PropertyList::DeleteProperty ( const std::string &  propertyKey)

Remove a property from the list/map by key.

Parameters
[in]propertyKeyThe key of the property to remove.
Returns
true if the property was found and removed, false otherwise.

Referenced by mitk::SceneReaderHelpers::StripTransientProperties().

◆ FromJSON()

void mitk::PropertyList::FromJSON ( const nlohmann::json &  j)

Deserialize the property list from JSON.

Note
Properties of a certain type can only be deserialized again if their type has been registered via the IPropertyDeserialization core service.
See also
CoreServices
IPropertyDeserialization::RegisterProperty

◆ Get() [1/5]

bool mitk::PropertyList::Get ( const char *  propertyKey,
bool &  boolValue 
) const

Shortcut for GetBoolProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[out]boolValueReceives the boolean value if the property exists.
Returns
true if the property was found, false otherwise.

◆ Get() [2/5]

bool mitk::PropertyList::Get ( const char *  propertyKey,
double &  doubleValue 
) const

Shortcut for GetDoubleProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[out]doubleValueReceives the double value if the property exists.
Returns
true if the property was found, false otherwise.

◆ Get() [3/5]

bool mitk::PropertyList::Get ( const char *  propertyKey,
float &  floatValue 
) const

Shortcut for GetFloatProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[out]floatValueReceives the float value if the property exists.
Returns
true if the property was found, false otherwise.

◆ Get() [4/5]

bool mitk::PropertyList::Get ( const char *  propertyKey,
int &  intValue 
) const

Shortcut for GetIntProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[out]intValueReceives the integer value if the property exists.
Returns
true if the property was found, false otherwise.

◆ Get() [5/5]

bool mitk::PropertyList::Get ( const char *  propertyKey,
std::string &  stringValue 
) const

Shortcut for GetStringProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[out]stringValueReceives the string value if the property exists.
Returns
true if the property was found, false otherwise.

◆ GetBoolProperty()

bool mitk::PropertyList::GetBoolProperty ( const char *  propertyKey,
bool &  boolValue 
) const

Convenience method to access the value of a BoolProperty.

Parameters
[in]propertyKeyThe key identifying the property.
[out]boolValueReceives the boolean value if the property exists.
Returns
true if the property was found, false otherwise.

◆ GetConstProperty()

BaseProperty::ConstPointer mitk::PropertyList::GetConstProperty ( const std::string &  propertyKey,
const std::string &  contextName = "",
bool  fallBackOnDefaultContext = true 
) const
overridevirtual

Retrieve a property by key (const version).

Parameters
[in]propertyKeyThe key identifying the property.
[in]contextNameIgnored in PropertyList (no context support). Provided for interface compatibility.
[in]fallBackOnDefaultContextIgnored in PropertyList.
Returns
A const smart pointer to the property, or nullptr if not found.
See also
IPropertyProvider

Implements mitk::IPropertyProvider.

Reimplemented in mitk::Label.

◆ GetDoubleProperty()

bool mitk::PropertyList::GetDoubleProperty ( const char *  propertyKey,
double &  doubleValue 
) const

Convenience method to access the value of a DoubleProperty.

Parameters
[in]propertyKeyThe key identifying the property.
[out]doubleValueReceives the double value if the property exists.
Returns
true if the property was found, false otherwise.

◆ GetFloatProperty()

bool mitk::PropertyList::GetFloatProperty ( const char *  propertyKey,
float &  floatValue 
) const

Convenience method to access the value of a FloatProperty.

Parameters
[in]propertyKeyThe key identifying the property.
[out]floatValueReceives the float value if the property exists.
Returns
true if the property was found, false otherwise.

◆ GetIntProperty()

bool mitk::PropertyList::GetIntProperty ( const char *  propertyKey,
int &  intValue 
) const

Convenience method to access the value of an IntProperty.

Parameters
[in]propertyKeyThe key identifying the property.
[out]intValueReceives the integer value if the property exists.
Returns
true if the property was found, false otherwise.

◆ GetMap()

const PropertyMap* mitk::PropertyList::GetMap ( ) const
inline

Get a read-only pointer to the internal property map.

Returns
Pointer to the internal PropertyMap.

Definition at line 431 of file mitkPropertyList.h.

Referenced by mitk::SceneReaderHelpers::StripTransientProperties().

◆ GetMTime()

itk::ModifiedTimeType mitk::PropertyList::GetMTime ( ) const
override

Get the modification timestamp of the list.

Returns the timestamp of the last change of the map or the last change of any of the properties stored in the list, whichever is later.

Returns
The modification time.

◆ GetNonConstProperty()

BaseProperty* mitk::PropertyList::GetNonConstProperty ( const std::string &  propertyKey,
const std::string &  contextName = "",
bool  fallBackOnDefaultContext = true 
)
overridevirtual

Retrieve a property by key (non-const version).

Parameters
[in]propertyKeyThe key identifying the property.
[in]contextNameIgnored in PropertyList.
[in]fallBackOnDefaultContextIgnored in PropertyList.
Returns
A raw pointer to the property, or nullptr if not found.
See also
IPropertyOwner

Implements mitk::IPropertyOwner.

Reimplemented in mitk::Label.

◆ GetProperty()

mitk::BaseProperty* mitk::PropertyList::GetProperty ( const std::string &  propertyKey) const

Get a property by its name.

Parameters
[in]propertyKeyThe key identifying the property.
Returns
A raw pointer to the property, or nullptr if no property with the given key exists.

◆ GetPropertyContextNames()

std::vector<std::string> mitk::PropertyList::GetPropertyContextNames ( ) const
overridevirtual

Return available property context names.

PropertyList does not support contexts, so this always returns an empty vector.

Returns
An empty vector.
See also
IPropertyProvider

Implements mitk::IPropertyProvider.

◆ GetPropertyKeys()

std::vector<std::string> mitk::PropertyList::GetPropertyKeys ( const std::string &  contextName = "",
bool  includeDefaultContext = false 
) const
overridevirtual

Retrieve all property keys.

Parameters
[in]contextNameIgnored in PropertyList (no context support). Keys are returned only when contextName is empty or includeDefaultContext is true.
[in]includeDefaultContextIf true and contextName is non-empty, default context keys are included.
Returns
A vector of all property key strings in this list.
See also
IPropertyProvider

Implements mitk::IPropertyProvider.

◆ GetPropertyValue()

template<typename T >
bool mitk::PropertyList::GetPropertyValue ( const char *  propertyKey,
T &  value 
) const
inline

Convenience access method for GenericProperty<T> properties.

Attempts to retrieve the value of a GenericProperty<T> identified by the given key.

Template Parameters
TThe value type of the GenericProperty.
Parameters
[in]propertyKeyThe key identifying the property.
[out]valueReceives the property value if found.
Returns
true if the property was found and is of the expected type, false otherwise.

Definition at line 209 of file mitkPropertyList.h.

References mitk::GenericProperty< T >::GetValue().

◆ GetStringProperty()

bool mitk::PropertyList::GetStringProperty ( const char *  propertyKey,
std::string &  stringValue 
) const

Convenience method to access the value of a StringProperty.

Parameters
[in]propertyKeyThe key identifying the property.
[out]stringValueReceives the string value if the property exists.
Returns
true if the property was found, false otherwise.

◆ IsEmpty()

bool mitk::PropertyList::IsEmpty ( ) const
inline

Check whether the property list contains no properties.

Returns
true if the list is empty, false otherwise.

Definition at line 438 of file mitkPropertyList.h.

◆ mitkClassMacroItkParent()

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

◆ mitkCloneMacro()

mitk::PropertyList::mitkCloneMacro ( Self  )
protected

◆ New()

static Pointer mitk::PropertyList::New ( )
static

Method for creation through the object factory.

◆ RemoveProperty()

void mitk::PropertyList::RemoveProperty ( const std::string &  propertyKey,
const std::string &  contextName = "",
bool  fallBackOnDefaultContext = false 
)
overridevirtual

Remove a property from the list by key.

Parameters
[in]propertyKeyThe key of the property to remove.
[in]contextNameIgnored in PropertyList.
[in]fallBackOnDefaultContextIgnored in PropertyList.
See also
IPropertyOwner

Implements mitk::IPropertyOwner.

◆ ReplaceProperty()

void mitk::PropertyList::ReplaceProperty ( const std::string &  propertyKey,
BaseProperty *  property 
)

Replace a property object in the list by a new one.

The actual property object is replaced, unlike SetProperty() which tries to assign the value to an existing property of the same type. This is useful when you want to change the type of a property (e.g., from BoolProperty to StringProperty) or to share the same property object among several PropertyList/DataNode instances for synchronization.

Parameters
[in]propertyKeyThe key for the property.
[in]propertyThe new property object. If nullptr, the call is ignored.
See also
SetProperty

◆ Set() [1/6]

void mitk::PropertyList::Set ( const char *  propertyKey,
bool  boolValue 
)

Shortcut for SetBoolProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[in]boolValueThe boolean value to set.

◆ Set() [2/6]

void mitk::PropertyList::Set ( const char *  propertyKey,
const char *  stringValue 
)

Shortcut for SetStringProperty() accepting a C-string.

Parameters
[in]propertyKeyThe key identifying the property.
[in]stringValueThe C-string value to set.

◆ Set() [3/6]

void mitk::PropertyList::Set ( const char *  propertyKey,
const std::string &  stringValue 
)

Shortcut for SetStringProperty() accepting a std::string.

Parameters
[in]propertyKeyThe key identifying the property.
[in]stringValueThe string value to set.

◆ Set() [4/6]

void mitk::PropertyList::Set ( const char *  propertyKey,
double  doubleValue 
)

Shortcut for SetDoubleProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[in]doubleValueThe double value to set.

◆ Set() [5/6]

void mitk::PropertyList::Set ( const char *  propertyKey,
float  floatValue 
)

Shortcut for SetFloatProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[in]floatValueThe float value to set.

◆ Set() [6/6]

void mitk::PropertyList::Set ( const char *  propertyKey,
int  intValue 
)

Shortcut for SetIntProperty().

Parameters
[in]propertyKeyThe key identifying the property.
[in]intValueThe integer value to set.

◆ SetBoolProperty()

void mitk::PropertyList::SetBoolProperty ( const char *  propertyKey,
bool  boolValue 
)

Convenience method to set the value of a BoolProperty.

Creates a new BoolProperty if the key does not exist yet.

Parameters
[in]propertyKeyThe key identifying the property.
[in]boolValueThe boolean value to set.

◆ SetDoubleProperty()

void mitk::PropertyList::SetDoubleProperty ( const char *  propertyKey,
double  doubleValue 
)

Convenience method to set the value of a DoubleProperty.

Creates a new DoubleProperty if the key does not exist yet.

Parameters
[in]propertyKeyThe key identifying the property.
[in]doubleValueThe double value to set.

◆ SetFloatProperty()

void mitk::PropertyList::SetFloatProperty ( const char *  propertyKey,
float  floatValue 
)

Convenience method to set the value of a FloatProperty.

Creates a new FloatProperty if the key does not exist yet.

Parameters
[in]propertyKeyThe key identifying the property.
[in]floatValueThe float value to set.

◆ SetIntProperty()

void mitk::PropertyList::SetIntProperty ( const char *  propertyKey,
int  intValue 
)

Convenience method to set the value of an IntProperty.

Creates a new IntProperty if the key does not exist yet.

Parameters
[in]propertyKeyThe key identifying the property.
[in]intValueThe integer value to set.

◆ SetProperty()

void mitk::PropertyList::SetProperty ( const std::string &  propertyKey,
BaseProperty *  property,
const std::string &  contextName = "",
bool  fallBackOnDefaultContext = false 
)
overridevirtual

Set a property in the list, preserving existing property type.

If a property with the given key already exists and has the same type, its value is updated via AssignProperty(). If the types differ, an error is logged and the property is not replaced (use ReplaceProperty() instead). If the key does not exist, the property is inserted.

Parameters
[in]propertyKeyThe key for the property. Must not be empty.
[in]propertyThe property to set. If nullptr, the call is ignored.
[in]contextNameIgnored in PropertyList.
[in]fallBackOnDefaultContextIgnored in PropertyList.
Precondition
propertyKey must be a non-empty string; otherwise an exception is thrown.
See also
ReplaceProperty
IPropertyOwner

Implements mitk::IPropertyOwner.

Reimplemented in mitk::Label.

◆ SetStringProperty()

void mitk::PropertyList::SetStringProperty ( const char *  propertyKey,
const char *  stringValue 
)

Convenience method to set the value of a StringProperty.

Creates a new StringProperty if the key does not exist yet.

Parameters
[in]propertyKeyThe key identifying the property.
[in]stringValueThe C-string value to set.

◆ ToJSON()

void mitk::PropertyList::ToJSON ( nlohmann::json &  j) const

Serialize the property list to JSON.

Note
Properties of a certain type can only be deserialized again if their type has been registered via the IPropertyDeserialization core service.
See also
CoreServices
IPropertyDeserialization::RegisterProperty

Member Data Documentation

◆ m_Properties

PropertyMap mitk::PropertyList::m_Properties
protected

Map of properties.

Definition at line 478 of file mitkPropertyList.h.


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