Medical Imaging Interaction Toolkit  2024.06.99-35a6d053
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 PropertyList Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
typedef std::map< std::string, BaseProperty::PointerPropertyMap
 
typedef std::pair< std::string, BaseProperty::PointerPropertyMapElementType
 

Public Member Functions

virtual std::vector< std::string > GetClassHierarchy () const
 
virtual const char * GetClassName () const
 
Pointer Clone () const
 
BaseProperty::ConstPointer GetConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const override
 Get property by its key. More...
 
std::vector< std::string > GetPropertyKeys (const std::string &contextName="", bool includeDefaultContext=false) const override
 Query keys of existing properties. More...
 
std::vector< std::string > GetPropertyContextNames () const override
 Query names of existing contexts. More...
 
BasePropertyGetNonConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) override
 Get property by its key. More...
 
void SetProperty (const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Add new or change existent property. More...
 
void RemoveProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Removes a property. If the property does not exist, nothing will be done. More...
 
mitk::BasePropertyGetProperty (const std::string &propertyKey) const
 Get a property by its name. More...
 
void ReplaceProperty (const std::string &propertyKey, BaseProperty *property)
 Set a property object in the list/map by reference. More...
 
void ConcatenatePropertyList (PropertyList *pList, bool replace=false)
 Set a property object in the list/map by reference. More...
 
template<typename T >
bool GetPropertyValue (const char *propertyKey, T &value) const
 Convenience access method for GenericProperty<T> properties (T being the type of the second parameter) 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 the above method. 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 the above method. 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 the above method. 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 the above method. 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 the above method. 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 the above method. 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 the above method. 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 the above method. 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 the above method. 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 the above method. More...
 
void Set (const char *propertyKey, const std::string &stringValue)
 ShortCut for the above method. More...
 
itk::ModifiedTimeType GetMTime () const override
 Get the timestamp of the last change of the map or the last change of one of the properties store in the list (whichever is later). More...
 
bool DeleteProperty (const std::string &propertyKey)
 Remove a property from the list/map. More...
 
const PropertyMapGetMap () const
 
bool IsEmpty () const
 
virtual void Clear ()
 
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
 
- Public Member Functions inherited from mitk::IPropertyProvider
virtual ~IPropertyProvider ()
 

Static Public Member Functions

static const char * GetStaticNameOfClass ()
 
static Pointer New ()
 

Protected Member Functions

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

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.

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 56 of file mitkPropertyList.h.

Member Typedef Documentation

◆ ConstPointer

Definition at line 59 of file mitkPropertyList.h.

◆ Pointer

◆ 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 65 of file mitkPropertyList.h.

◆ PropertyMapElementType

Definition at line 72 of file mitkPropertyList.h.

◆ Self

Definition at line 59 of file mitkPropertyList.h.

◆ Superclass

typedef itk::Object mitk::PropertyList::Superclass

Definition at line 59 of file mitkPropertyList.h.

Constructor & Destructor Documentation

◆ PropertyList() [1/2]

mitk::PropertyList::PropertyList ( )
protected

◆ PropertyList() [2/2]

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

◆ ~PropertyList()

mitk::PropertyList::~PropertyList ( )
overrideprotected

Member Function Documentation

◆ Clear()

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

◆ Clone()

Pointer mitk::PropertyList::Clone ( ) const

◆ ConcatenatePropertyList()

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

Set a property object in the list/map by reference.

◆ DeleteProperty()

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

Remove a property from the list/map.

◆ FromJSON()

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

Deserialize the property list from JSON.

Note
Properties of a certain type can only be deseralized 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 the above method.

◆ Get() [2/5]

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

ShortCut for the above method.

◆ Get() [3/5]

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

ShortCut for the above method.

◆ Get() [4/5]

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

ShortCut for the above method.

◆ Get() [5/5]

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

ShortCut for the above method.

◆ GetBoolProperty()

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

Convenience method to access the value of a BoolProperty.

◆ GetClassHierarchy()

virtual std::vector<std::string> mitk::PropertyList::GetClassHierarchy ( ) const
inlinevirtual

Definition at line 59 of file mitkPropertyList.h.

◆ GetClassName()

virtual const char* mitk::PropertyList::GetClassName ( ) const
virtual

◆ GetConstProperty()

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

Get property by its key.

Parameters
[in]propertyKeyKey of property.
[in]contextNameOptional, default is empty string (default context). Search in specified context.
[in]fallBackOnDefaultContextOptional, default is true. Also search in default context if property was not found in given context.
Returns
Found property, nullptr otherwise.

Implements mitk::IPropertyProvider.

◆ GetDoubleProperty()

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

Convenience method to access the value of a DoubleProperty.

◆ GetFloatProperty()

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

Convenience method to access the value of a FloatProperty.

◆ GetIntProperty()

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

Convenience method to access the value of an IntProperty.

◆ GetMap()

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

Definition at line 225 of file mitkPropertyList.h.

◆ GetMTime()

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

Get the timestamp of the last change of the map or the last change of one of the properties store in the list (whichever is later).

◆ GetNonConstProperty()

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

Get property by its key.

Parameters
[in]propertyKeyKey of property.
[in]contextNameOptional, default is empty string (default context). Search in specified context.
[in]fallBackOnDefaultContextOptional, default is true. Also search in default context if property was not found in given context.
Returns
Found property, nullptr otherwise.

Implements mitk::IPropertyOwner.

◆ GetProperty()

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

Get a property by its name.

◆ GetPropertyContextNames()

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

Query names of existing contexts.

Returns
List of context names.

Implements mitk::IPropertyProvider.

◆ GetPropertyKeys()

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

Query keys of existing properties.

Parameters
[in]contextNameOptional, default is empty string (default context). Search in specified context.
[in]includeDefaultContextOptional, default is false. Include default context.
Returns
List of property keys.

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 (T being the type of the second parameter)

Returns
true property was found

Definition at line 109 of file mitkPropertyList.h.

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

◆ GetStaticNameOfClass()

static const char* mitk::PropertyList::GetStaticNameOfClass ( )
inlinestatic

Definition at line 59 of file mitkPropertyList.h.

◆ GetStringProperty()

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

Convenience method to access the value of a StringProperty.

◆ IsEmpty()

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

Definition at line 226 of file mitkPropertyList.h.

◆ 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

Removes a property. If the property does not exist, nothing will be done.

Parameters
[in]propertyKeyKey of property.
[in]contextNameOptional, default is empty string (default context). Context in which the property is removed.
[in]fallBackOnDefaultContextOptional, default is false. Remove property in default context if given context does not exist.
Precondition
If a context is specified by contextName, this context must be known by the owner or fallBackOnDefaultContext must be true. If violated an mitk::Exception is thrown.
propertyKey must be a none empty string. If violated an mitk::Exception is thrown.

Implements mitk::IPropertyOwner.

◆ ReplaceProperty()

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

Set a property object in the list/map by reference.

The actual OBJECT holding the value of the property is replaced by this function. This is useful if you want to change the type of the property, like from BoolProperty to StringProperty. Another use is to share one and the same property object among several PropertyList/DataNode objects, which makes them appear synchronized.

◆ Set() [1/6]

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

ShortCut for the above method.

◆ Set() [2/6]

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

ShortCut for the above method.

◆ Set() [3/6]

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

ShortCut for the above method.

◆ Set() [4/6]

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

ShortCut for the above method.

◆ Set() [5/6]

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

ShortCut for the above method.

◆ Set() [6/6]

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

ShortCut for the above method.

◆ SetBoolProperty()

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

Convenience method to set the value of a BoolProperty.

◆ SetDoubleProperty()

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

Convenience method to set the value of a DoubleProperty.

◆ SetFloatProperty()

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

Convenience method to set the value of a FloatProperty.

◆ SetIntProperty()

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

Convenience method to set the value of an IntProperty.

◆ SetProperty()

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

Add new or change existent property.

Parameters
[in]propertyKeyKey of property.
[in]propertyThe actual property.
[in]contextNameOptional, default is empty string (default context). Context in which the property is set.
[in]fallBackOnDefaultContextOptional, default is false. Set property in default context if given context does not exist.
Precondition
If a context is specified by contextName, this context must be known by the owner or fallBackOnDefaultContext must be true. If violated an mitk::Exception is thrown.
propertyKey must be a none empty string. If violated an mitk::Exception is thrown.

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.

◆ ToJSON()

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

Serialize the property list to JSON.

Note
Properties of a certain type can only be deseralized 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 260 of file mitkPropertyList.h.


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