|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Key-value list holding instances of BaseProperty. More...
#include <mitkPropertyList.h>


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... | |
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.
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.
| 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.
| typedef std::pair<std::string, BaseProperty::Pointer> mitk::PropertyList::PropertyMapElementType |
Definition at line 70 of file mitkPropertyList.h.
|
protected |
|
protected |
|
overrideprotected |
|
virtual |
Remove all properties from the list.
| Pointer mitk::PropertyList::Clone | ( | ) | const |
| 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.
| [in] | pList | The property list to merge. If nullptr, the call is ignored. |
| [in] | replace | If true, existing properties are replaced via ReplaceProperty(). If false (default), existing properties are updated via SetProperty() (type-safe assignment). |
| bool mitk::PropertyList::DeleteProperty | ( | const std::string & | propertyKey | ) |
Remove a property from the list/map by key.
| [in] | propertyKey | The key of the property to remove. |
true if the property was found and removed, false otherwise. Referenced by mitk::SceneReaderHelpers::StripTransientProperties().
| void mitk::PropertyList::FromJSON | ( | const nlohmann::json & | j | ) |
Deserialize the property list from JSON.
| bool mitk::PropertyList::Get | ( | const char * | propertyKey, |
| bool & | boolValue | ||
| ) | const |
Shortcut for GetBoolProperty().
| [in] | propertyKey | The key identifying the property. |
| [out] | boolValue | Receives the boolean value if the property exists. |
true if the property was found, false otherwise. | bool mitk::PropertyList::Get | ( | const char * | propertyKey, |
| double & | doubleValue | ||
| ) | const |
Shortcut for GetDoubleProperty().
| [in] | propertyKey | The key identifying the property. |
| [out] | doubleValue | Receives the double value if the property exists. |
true if the property was found, false otherwise. | bool mitk::PropertyList::Get | ( | const char * | propertyKey, |
| float & | floatValue | ||
| ) | const |
Shortcut for GetFloatProperty().
| [in] | propertyKey | The key identifying the property. |
| [out] | floatValue | Receives the float value if the property exists. |
true if the property was found, false otherwise. | bool mitk::PropertyList::Get | ( | const char * | propertyKey, |
| int & | intValue | ||
| ) | const |
Shortcut for GetIntProperty().
| [in] | propertyKey | The key identifying the property. |
| [out] | intValue | Receives the integer value if the property exists. |
true if the property was found, false otherwise. | bool mitk::PropertyList::Get | ( | const char * | propertyKey, |
| std::string & | stringValue | ||
| ) | const |
Shortcut for GetStringProperty().
| [in] | propertyKey | The key identifying the property. |
| [out] | stringValue | Receives the string value if the property exists. |
true if the property was found, false otherwise. | bool mitk::PropertyList::GetBoolProperty | ( | const char * | propertyKey, |
| bool & | boolValue | ||
| ) | const |
Convenience method to access the value of a BoolProperty.
| [in] | propertyKey | The key identifying the property. |
| [out] | boolValue | Receives the boolean value if the property exists. |
true if the property was found, false otherwise.
|
overridevirtual |
Retrieve a property by key (const version).
| [in] | propertyKey | The key identifying the property. |
| [in] | contextName | Ignored in PropertyList (no context support). Provided for interface compatibility. |
| [in] | fallBackOnDefaultContext | Ignored in PropertyList. |
nullptr if not found.Implements mitk::IPropertyProvider.
Reimplemented in mitk::Label.
| bool mitk::PropertyList::GetDoubleProperty | ( | const char * | propertyKey, |
| double & | doubleValue | ||
| ) | const |
Convenience method to access the value of a DoubleProperty.
| [in] | propertyKey | The key identifying the property. |
| [out] | doubleValue | Receives the double value if the property exists. |
true if the property was found, false otherwise. | bool mitk::PropertyList::GetFloatProperty | ( | const char * | propertyKey, |
| float & | floatValue | ||
| ) | const |
Convenience method to access the value of a FloatProperty.
| [in] | propertyKey | The key identifying the property. |
| [out] | floatValue | Receives the float value if the property exists. |
true if the property was found, false otherwise. | bool mitk::PropertyList::GetIntProperty | ( | const char * | propertyKey, |
| int & | intValue | ||
| ) | const |
Convenience method to access the value of an IntProperty.
| [in] | propertyKey | The key identifying the property. |
| [out] | intValue | Receives the integer value if the property exists. |
true if the property was found, false otherwise.
|
inline |
Get a read-only pointer to the internal property map.
Definition at line 431 of file mitkPropertyList.h.
Referenced by mitk::SceneReaderHelpers::StripTransientProperties().
|
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.
|
overridevirtual |
Retrieve a property by key (non-const version).
| [in] | propertyKey | The key identifying the property. |
| [in] | contextName | Ignored in PropertyList. |
| [in] | fallBackOnDefaultContext | Ignored in PropertyList. |
nullptr if not found.Implements mitk::IPropertyOwner.
Reimplemented in mitk::Label.
| mitk::BaseProperty* mitk::PropertyList::GetProperty | ( | const std::string & | propertyKey | ) | const |
Get a property by its name.
| [in] | propertyKey | The key identifying the property. |
nullptr if no property with the given key exists.
|
overridevirtual |
Return available property context names.
PropertyList does not support contexts, so this always returns an empty vector.
Implements mitk::IPropertyProvider.
|
overridevirtual |
Retrieve all property keys.
| [in] | contextName | Ignored in PropertyList (no context support). Keys are returned only when contextName is empty or includeDefaultContext is true. |
| [in] | includeDefaultContext | If true and contextName is non-empty, default context keys are included. |
Implements mitk::IPropertyProvider.
|
inline |
Convenience access method for GenericProperty<T> properties.
Attempts to retrieve the value of a GenericProperty<T> identified by the given key.
| T | The value type of the GenericProperty. |
| [in] | propertyKey | The key identifying the property. |
| [out] | value | Receives the property value if found. |
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().
| bool mitk::PropertyList::GetStringProperty | ( | const char * | propertyKey, |
| std::string & | stringValue | ||
| ) | const |
Convenience method to access the value of a StringProperty.
| [in] | propertyKey | The key identifying the property. |
| [out] | stringValue | Receives the string value if the property exists. |
true if the property was found, false otherwise.
|
inline |
Check whether the property list contains no properties.
true if the list is empty, false otherwise. Definition at line 438 of file mitkPropertyList.h.
| mitk::PropertyList::mitkClassMacroItkParent | ( | PropertyList | , |
| itk::Object | |||
| ) |
|
protected |
|
static |
Method for creation through the object factory.
|
overridevirtual |
Remove a property from the list by key.
| [in] | propertyKey | The key of the property to remove. |
| [in] | contextName | Ignored in PropertyList. |
| [in] | fallBackOnDefaultContext | Ignored in PropertyList. |
Implements mitk::IPropertyOwner.
| 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.
| [in] | propertyKey | The key for the property. |
| [in] | property | The new property object. If nullptr, the call is ignored. |
| void mitk::PropertyList::Set | ( | const char * | propertyKey, |
| bool | boolValue | ||
| ) |
Shortcut for SetBoolProperty().
| [in] | propertyKey | The key identifying the property. |
| [in] | boolValue | The boolean value to set. |
| void mitk::PropertyList::Set | ( | const char * | propertyKey, |
| const char * | stringValue | ||
| ) |
Shortcut for SetStringProperty() accepting a C-string.
| [in] | propertyKey | The key identifying the property. |
| [in] | stringValue | The C-string value to set. |
| void mitk::PropertyList::Set | ( | const char * | propertyKey, |
| const std::string & | stringValue | ||
| ) |
Shortcut for SetStringProperty() accepting a std::string.
| [in] | propertyKey | The key identifying the property. |
| [in] | stringValue | The string value to set. |
| void mitk::PropertyList::Set | ( | const char * | propertyKey, |
| double | doubleValue | ||
| ) |
Shortcut for SetDoubleProperty().
| [in] | propertyKey | The key identifying the property. |
| [in] | doubleValue | The double value to set. |
| void mitk::PropertyList::Set | ( | const char * | propertyKey, |
| float | floatValue | ||
| ) |
Shortcut for SetFloatProperty().
| [in] | propertyKey | The key identifying the property. |
| [in] | floatValue | The float value to set. |
| void mitk::PropertyList::Set | ( | const char * | propertyKey, |
| int | intValue | ||
| ) |
Shortcut for SetIntProperty().
| [in] | propertyKey | The key identifying the property. |
| [in] | intValue | The integer value to set. |
| 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.
| [in] | propertyKey | The key identifying the property. |
| [in] | boolValue | The boolean value to set. |
| 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.
| [in] | propertyKey | The key identifying the property. |
| [in] | doubleValue | The double value to set. |
| 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.
| [in] | propertyKey | The key identifying the property. |
| [in] | floatValue | The float value to set. |
| 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.
| [in] | propertyKey | The key identifying the property. |
| [in] | intValue | The integer value to set. |
|
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.
| [in] | propertyKey | The key for the property. Must not be empty. |
| [in] | property | The property to set. If nullptr, the call is ignored. |
| [in] | contextName | Ignored in PropertyList. |
| [in] | fallBackOnDefaultContext | Ignored in PropertyList. |
propertyKey must be a non-empty string; otherwise an exception is thrown.Implements mitk::IPropertyOwner.
Reimplemented in mitk::Label.
| 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.
| [in] | propertyKey | The key identifying the property. |
| [in] | stringValue | The C-string value to set. |
| void mitk::PropertyList::ToJSON | ( | nlohmann::json & | j | ) | const |
Serialize the property list to JSON.
|
protected |
Map of properties.
Definition at line 478 of file mitkPropertyList.h.