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

A variant-like container for storing typed configuration values. More...

#include <mitkConfigurationHolder.h>

Public Types

enum  ValueType {
  DT_UNINIZIALIZED , DT_BOOL , DT_UINT , DT_INT ,
  DT_DOUBLE , DT_STRING , DT_GROUP
}
 Enumerates the data types that a ConfigurationHolder can store. More...
 

Public Member Functions

 ConfigurationHolder ()
 Construct an uninitialized ConfigurationHolder. More...
 
void SetBool (bool value)
 Store a boolean value. More...
 
void SetUnsignedInt (unsigned int value)
 Store an unsigned integer value. More...
 
void SetInt (int value)
 Store a signed integer value. More...
 
void SetDouble (double value)
 Store a double-precision floating-point value. More...
 
void SetString (std::string value)
 Store a string value. More...
 
void ClearGroup ()
 Clear all children from the group and set the type to DT_GROUP. More...
 
void AddToGroup (std::string id, const ConfigurationHolder &value)
 Add a named child to the group. More...
 
bool AsBool ()
 Convert the stored value to bool. More...
 
unsigned int AsUnsignedInt ()
 Convert the stored value to unsigned int. More...
 
int AsInt ()
 Convert the stored value to int. More...
 
double AsDouble ()
 Convert the stored value to double. More...
 
std::string AsString ()
 Convert the stored value to string. More...
 
bool AsBool (bool value)
 Convert the stored value to bool, returning a default on failure. More...
 
unsigned int AsUnsignedInt (unsigned int value)
 Convert the stored value to unsigned int, returning a default on failure. More...
 
int AsInt (int value)
 Convert the stored value to int, returning a default on failure. More...
 
double AsDouble (double value)
 Convert the stored value to double, returning a default on failure. More...
 
std::string AsString (std::string value)
 Convert the stored value to string, returning a default on failure. More...
 
std::vector< std::string > AsStringVector ()
 Convert group children to a vector of strings. More...
 
ConfigurationHolder & At (std::string id)
 Access a child ConfigurationHolder by identifier. More...
 

Detailed Description

A variant-like container for storing typed configuration values.

ConfigurationHolder stores a single value of one of several supported types (bool, unsigned int, int, double, string) or a named group of child ConfigurationHolder objects. The stored type is tracked internally, and accessor methods attempt automatic type conversion when possible.

When a value has not been set (DT_UNINIZIALIZED) or when a group value cannot be converted, the accessor methods throw a mitk::Exception.

See also
ConfigFileReader
AbstractGlobalImageFeature

Definition at line 42 of file mitkConfigurationHolder.h.

Member Enumeration Documentation

◆ ValueType

Enumerates the data types that a ConfigurationHolder can store.

Enumerator
DT_UNINIZIALIZED 

No value has been set yet.

DT_BOOL 

Boolean value.

DT_UINT 

Unsigned integer value.

DT_INT 

Signed integer value.

DT_DOUBLE 

Double-precision floating-point value.

DT_STRING 

String value.

DT_GROUP 

Group of named ConfigurationHolder children.

Definition at line 48 of file mitkConfigurationHolder.h.

Constructor & Destructor Documentation

◆ ConfigurationHolder()

mitk::ConfigurationHolder::ConfigurationHolder ( )

Construct an uninitialized ConfigurationHolder.

Member Function Documentation

◆ AddToGroup()

void mitk::ConfigurationHolder::AddToGroup ( std::string  id,
const ConfigurationHolder &  value 
)

Add a named child to the group.

Sets the value type to DT_GROUP.

Parameters
[in]idThe identifier for the child entry.
[in]valueThe ConfigurationHolder to add as a child.

◆ AsBool() [1/2]

bool mitk::ConfigurationHolder::AsBool ( )

Convert the stored value to bool.

Returns
The value converted to bool.
Exceptions
mitk::ExceptionIf the value is uninitialized or is group data.

◆ AsBool() [2/2]

bool mitk::ConfigurationHolder::AsBool ( bool  value)

Convert the stored value to bool, returning a default on failure.

Parameters
[in]valueDefault value returned if conversion fails.
Returns
The converted value, or the default if a mitk::Exception is thrown.

◆ AsDouble() [1/2]

double mitk::ConfigurationHolder::AsDouble ( )

Convert the stored value to double.

Returns
The value converted to double.
Exceptions
mitk::ExceptionIf the value is uninitialized or is group data.

◆ AsDouble() [2/2]

double mitk::ConfigurationHolder::AsDouble ( double  value)

Convert the stored value to double, returning a default on failure.

Parameters
[in]valueDefault value returned if conversion fails.
Returns
The converted value, or the default if a mitk::Exception is thrown.

◆ AsInt() [1/2]

int mitk::ConfigurationHolder::AsInt ( )

Convert the stored value to int.

Returns
The value converted to int.
Exceptions
mitk::ExceptionIf the value is uninitialized or is group data.

◆ AsInt() [2/2]

int mitk::ConfigurationHolder::AsInt ( int  value)

Convert the stored value to int, returning a default on failure.

Parameters
[in]valueDefault value returned if conversion fails.
Returns
The converted value, or the default if a mitk::Exception is thrown.

◆ AsString() [1/2]

std::string mitk::ConfigurationHolder::AsString ( )

Convert the stored value to string.

Returns
The value converted to string.
Exceptions
mitk::ExceptionIf the value is uninitialized or is group data.

◆ AsString() [2/2]

std::string mitk::ConfigurationHolder::AsString ( std::string  value)

Convert the stored value to string, returning a default on failure.

Parameters
[in]valueDefault value returned if conversion fails.
Returns
The converted value, or the default if a mitk::Exception is thrown.

◆ AsStringVector()

std::vector<std::string> mitk::ConfigurationHolder::AsStringVector ( )

Convert group children to a vector of strings.

Each child's value is converted to string via AsString().

Returns
A vector of string representations of all group children.
Exceptions
mitk::ExceptionIf the value type is not DT_GROUP.

◆ AsUnsignedInt() [1/2]

unsigned int mitk::ConfigurationHolder::AsUnsignedInt ( )

Convert the stored value to unsigned int.

Returns
The value converted to unsigned int.
Exceptions
mitk::ExceptionIf the value is uninitialized or is group data.

◆ AsUnsignedInt() [2/2]

unsigned int mitk::ConfigurationHolder::AsUnsignedInt ( unsigned int  value)

Convert the stored value to unsigned int, returning a default on failure.

Parameters
[in]valueDefault value returned if conversion fails.
Returns
The converted value, or the default if a mitk::Exception is thrown.

◆ At()

ConfigurationHolder& mitk::ConfigurationHolder::At ( std::string  id)

Access a child ConfigurationHolder by identifier.

If no child with the given id exists, a default-constructed entry is created.

Parameters
[in]idThe identifier of the child to access.
Returns
Reference to the child ConfigurationHolder.

◆ ClearGroup()

void mitk::ConfigurationHolder::ClearGroup ( )

Clear all children from the group and set the type to DT_GROUP.

◆ SetBool()

void mitk::ConfigurationHolder::SetBool ( bool  value)

Store a boolean value.

Parameters
[in]valueThe boolean value to store.

◆ SetDouble()

void mitk::ConfigurationHolder::SetDouble ( double  value)

Store a double-precision floating-point value.

Parameters
[in]valueThe double value to store.

◆ SetInt()

void mitk::ConfigurationHolder::SetInt ( int  value)

Store a signed integer value.

Parameters
[in]valueThe signed integer value to store.

◆ SetString()

void mitk::ConfigurationHolder::SetString ( std::string  value)

Store a string value.

Parameters
[in]valueThe string value to store.

◆ SetUnsignedInt()

void mitk::ConfigurationHolder::SetUnsignedInt ( unsigned int  value)

Store an unsigned integer value.

Parameters
[in]valueThe unsigned integer value to store.

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