Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
mitk::EnumerationProperty Class Reference

#include <mitkEnumerationProperty.h>

Inheritance diagram for mitk::EnumerationProperty:
Collaboration diagram for mitk::EnumerationProperty:

Public Types

typedef EnumerationProperty Self
 
typedef BaseProperty Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
typedef unsigned int IdType
 
typedef std::map< IdType, std::string > EnumIdsContainerType
 
typedef std::map< std::string, IdTypeEnumStringsContainerType
 
typedef EnumIdsContainerType::const_iterator EnumConstIterator
 
- Public Types inherited from mitk::BaseProperty
typedef BaseProperty Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 

Public Member Functions

virtual std::vector< std::string > GetClassHierarchy () const override
 
virtual const char * GetClassName () const
 
Pointer Clone () const
 
virtual bool AddEnum (const std::string &name, const IdType &id)
 
virtual bool SetValue (const std::string &name)
 
virtual bool SetValue (const IdType &id)
 
virtual IdType GetValueAsId () const
 
std::string GetValueAsString () const override
 
virtual void Clear ()
 
virtual EnumIdsContainerType::size_type Size () const
 
virtual EnumConstIterator Begin () const
 
virtual EnumConstIterator End () const
 
virtual std::string GetEnumString (const IdType &id) const
 
virtual IdType GetEnumId (const std::string &name) const
 
virtual bool IsValidEnumerationValue (const IdType &id) const
 
virtual bool IsValidEnumerationValue (const std::string &name) const
 
const EnumIdsContainerTypeGetEnumIds () const
 
const EnumStringsContainerTypeGetEnumStrings () const
 
EnumIdsContainerTypeGetEnumIds ()
 
EnumStringsContainerTypeGetEnumStrings ()
 
bool ToJSON (nlohmann::json &j) const override
 
bool FromJSON (const nlohmann::json &j) override
 
EnumerationPropertyoperator= (const EnumerationProperty &)=delete
 
BasePropertyoperator= (const BaseProperty &property)
 Assigns property to this BaseProperty instance. More...
 
- Public Member Functions inherited from mitk::BaseProperty
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...
 

Static Public Member Functions

static const char * GetStaticNameOfClass ()
 
static Pointer New ()
 
- Static Public Member Functions inherited from mitk::BaseProperty
static const char * GetStaticNameOfClass ()
 

Protected Member Functions

 EnumerationProperty ()
 
 EnumerationProperty (const EnumerationProperty &)
 
bool IsEqual (const BaseProperty &property) const override
 
bool Assign (const BaseProperty &property) override
 
virtual itk::LightObject::Pointer InternalClone () const override
 
- Protected Member Functions inherited from mitk::BaseProperty
 BaseProperty ()
 
 BaseProperty (const BaseProperty &other)
 
 ~BaseProperty () override
 

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

This class may be used to store properties similar to enumeration values. Each enumeration value is identified by an id and a name. Note that both name and id must be unique. Add enumeration values before you use the Get/SetValue methods.

To use this class, create a subclass that adds the possible enumeration values in its constructor. You should override AddEnum() as protected so that the user isn't able to add invalid enumeration values.

As example see mitk::VtkRepresentationProperty or mitk::VtkInterpolationProperty.

Definition at line 43 of file mitkEnumerationProperty.h.

Member Typedef Documentation

◆ ConstPointer

◆ EnumConstIterator

typedef EnumIdsContainerType::const_iterator mitk::EnumerationProperty::EnumConstIterator

Type used for iterators over all defined enumeration values.

Definition at line 68 of file mitkEnumerationProperty.h.

◆ EnumIdsContainerType

Type used to store a mapping from enumeration id to enumeration name.

Definition at line 58 of file mitkEnumerationProperty.h.

◆ EnumStringsContainerType

Type used to store a mapping from enumeration name to enumeration id.

Definition at line 63 of file mitkEnumerationProperty.h.

◆ IdType

typedef unsigned int mitk::EnumerationProperty::IdType

Represents the unique id which is assigned to each enumeration name.

Definition at line 48 of file mitkEnumerationProperty.h.

◆ Pointer

◆ Self

◆ Superclass

Constructor & Destructor Documentation

◆ EnumerationProperty() [1/2]

mitk::EnumerationProperty::EnumerationProperty ( )
protected

Default constructor. The current value of the enumeration is undefined.

◆ EnumerationProperty() [2/2]

mitk::EnumerationProperty::EnumerationProperty ( const EnumerationProperty )
protected

Member Function Documentation

◆ AddEnum()

virtual bool mitk::EnumerationProperty::AddEnum ( const std::string &  name,
const IdType id 
)
virtual

Adds an enumeration value into the enumeration. The name and id provided must be unique. This is checked while adding the new enumeration value. If it is not unique, false is returned. If addition was successful, true is returned.

Parameters
nameThe unique name of the enumeration value
idThe unique id of the enumeration value
Returns
True, if the name/id combination was successfully added to the enumeration values. Otherwise false.

Reimplemented in mitk::RenderingModeProperty, mitk::PlaneOrientationProperty, mitk::PointSetShapeProperty, mitk::GridRepresentationProperty, mitk::VtkInterpolationProperty, mitk::VtkRepresentationProperty, mitk::VtkScalarModeProperty, mitk::VtkResliceInterpolationProperty, mitk::GridVolumeMapperProperty, mitk::RegEvalStyleProperty, mitk::RegEvalWipeStyleProperty, mitk::RegVisColorStyleProperty, mitk::RegVisDirectionProperty, mitk::RegVisStyleProperty, and mitk::PlanarFigureControlPointStyleProperty.

◆ Assign()

bool mitk::EnumerationProperty::Assign ( const BaseProperty )
overrideprotectedvirtual

Override this method in subclasses to implement a meaningful assignment. The property argument is guaranteed to be castable to the type of the implementing subclass.

Warning
This is not yet exception aware/safe and if this method returns false, this property's state might be undefined.
Returns
True if the argument could be assigned to this property.

Implements mitk::BaseProperty.

◆ Begin()

virtual EnumConstIterator mitk::EnumerationProperty::Begin ( ) const
virtual

Provides access to the set of enumeration values. The name can be accessed with iterator->second, the id via iterator->first.

Returns
An iterator over all enumeration values.

◆ Clear()

virtual void mitk::EnumerationProperty::Clear ( )
virtual

Clears all enumerations including the current one.

◆ Clone()

Pointer mitk::EnumerationProperty::Clone ( ) const

◆ End()

virtual EnumConstIterator mitk::EnumerationProperty::End ( ) const
virtual

Specifies the end of the range of enumeration values.

Returns
An iterator pointing past the last enumeration values.

◆ FromJSON()

bool mitk::EnumerationProperty::FromJSON ( const nlohmann::json j)
overridevirtual

Deserializes the property to JSON.

Note
Classes deriving from EnumerationProperty are covered by this implementation and do not need to override this method again.

Implements mitk::BaseProperty.

◆ GetClassHierarchy()

◆ GetClassName()

◆ GetEnumId()

virtual IdType mitk::EnumerationProperty::GetEnumId ( const std::string &  name) const
virtual

Returns the id for the given name.

Parameters
nameThe enumeration name for which the id should be determined. If the name is invalid, the return value is unspecified.
Returns
The id of the determined enumeration value.

◆ GetEnumIds() [1/2]

EnumIdsContainerType& mitk::EnumerationProperty::GetEnumIds ( )

◆ GetEnumIds() [2/2]

const EnumIdsContainerType& mitk::EnumerationProperty::GetEnumIds ( ) const

◆ GetEnumString()

virtual std::string mitk::EnumerationProperty::GetEnumString ( const IdType id) const
virtual

Returns the name for the given id.

Parameters
idThe id for which the name should be determined. If the id is invalid, the return value is unspecified.
Returns
The name of the determined enumeration value.

◆ GetEnumStrings() [1/2]

EnumStringsContainerType& mitk::EnumerationProperty::GetEnumStrings ( )

◆ GetEnumStrings() [2/2]

const EnumStringsContainerType& mitk::EnumerationProperty::GetEnumStrings ( ) const

◆ GetStaticNameOfClass()

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

Definition at line 46 of file mitkEnumerationProperty.h.

◆ GetValueAsId()

virtual IdType mitk::EnumerationProperty::GetValueAsId ( ) const
virtual

Returns the id of the current enumeration value. If it was not set so far, the return value is unspecified.

◆ GetValueAsString()

std::string mitk::EnumerationProperty::GetValueAsString ( ) const
overridevirtual

Returns the name of the current enumeration value. If it was not set so far, the return value is unspecified.

Reimplemented from mitk::BaseProperty.

◆ InternalClone()

virtual itk::LightObject::Pointer mitk::EnumerationProperty::InternalClone ( ) const
inlineoverrideprotectedvirtual

Definition at line 195 of file mitkEnumerationProperty.h.

◆ IsEqual()

bool mitk::EnumerationProperty::IsEqual ( const BaseProperty property) const
overrideprotectedvirtual

Override this method in subclasses to implement a meaningful comparison. The property argument is guaranteed to be castable to the type of the implementing subclass.

Implements mitk::BaseProperty.

◆ IsValidEnumerationValue() [1/2]

virtual bool mitk::EnumerationProperty::IsValidEnumerationValue ( const IdType id) const
virtual

Determines if a given id is valid.

Parameters
idThe id to check
Returns
True if the given id is valid. Otherwise false.

◆ IsValidEnumerationValue() [2/2]

virtual bool mitk::EnumerationProperty::IsValidEnumerationValue ( const std::string &  name) const
virtual

Determines if a given name is valid.

Parameters
nameThe name to check
Returns
True if the given name is valid. Otherwise false.

◆ New()

static Pointer mitk::EnumerationProperty::New ( )
static

◆ operator=() [1/2]

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.

◆ operator=() [2/2]

EnumerationProperty& mitk::EnumerationProperty::operator= ( const EnumerationProperty )
delete

◆ SetValue() [1/2]

virtual bool mitk::EnumerationProperty::SetValue ( const IdType id)
virtual

Sets the current value of the enumeration.

Parameters
idThe id of the enumeration value to set
Returns
True, if the value was successfully set. Otherwise false.

◆ SetValue() [2/2]

virtual bool mitk::EnumerationProperty::SetValue ( const std::string &  name)
virtual

Sets the current value of the enumeration.

Parameters
nameThe name of the enumeration value to set
Returns
True if the value was successfully set. Otherwise false.

◆ Size()

virtual EnumIdsContainerType::size_type mitk::EnumerationProperty::Size ( ) const
virtual

Determines the number of enumeration values.

◆ ToJSON()

bool mitk::EnumerationProperty::ToJSON ( nlohmann::json j) const
overridevirtual

Serializes the property to JSON.

Note
Classes deriving from EnumerationProperty are covered by this implementation and do not need to override this method again.

Implements mitk::BaseProperty.


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