Loading...
Searching...
No Matches
itk::ParameterMapInterface Class Reference

`#include <itkParameterMapInterface.h>`

## Detailed Description

Implements functionality to get parameters from a parameter map.

This class requires an std::map of parameter names and values, specified as strings. Such a map can be created by the related class itk::ParameterFileParser. This class implements functionality to get parameters from this map and return them in the desired type. The function that takes care of that is:
ReadParameter( T parameterValue, std::string parameterName, ... )
which is templated over T. For convenience, several flavors of ReadParameter() exist.

The layout of ReadParameter is specified below.

Warnings are created if the following two conditions are both satisfied: 1) ReadParameter() is called with the function argument printWarningToStream set to true. 2) The global member variable m_PrintErrorMessages is true.

This class can be used in the following way:
itk::ParameterMapInterface::Pointer p_interface = itk::ParameterMapInterface::New(); p_interface->SetParameterMap( parser->GetParameterMap() ); p_interface->PrintErrorMessages( true ); unsigned long parameterValue = 3; unsigned int index = 2; bool printWarning = true; std::string warningMessage = ""; bool success = p_interface->ReadParameter( parameterValue, "ParameterName", index, printWarning, warningMessage );

Note that some of the templated functions are defined in the header to get it compiling on some platforms.

See also
  itk::ParameterFileParser

Definition at line 78 of file itkParameterMapInterface.h.

Inheritance diagram for itk::ParameterMapInterface:
[legend]

## Public Types

using | ConstPointer = SmartPointer<const Self>
using | ParameterMapType = ParameterFileParser::ParameterMapType
using | ParameterValuesType = ParameterFileParser::ParameterValuesType
using | Pointer = SmartPointer<Self>
using | Self = ParameterMapInterface
using | Superclass = Object

## Public Member Functions

std::vcl_size_t | CountNumberOfParameterEntries (const std::string &parameterName) const
virtual const char * | GetClassName () const
virtual bool | GetPrintErrorMessages () const
std::vector< std::string > | GetValues (const std::string &parameterName) const
bool | HasParameter (const std::string &parameterName) const
| ITK_DISALLOW_COPY_AND_MOVE (ParameterMapInterface)
bool | ReadParameter (bool &parameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool produceWarningMessage, std::string &warningMessage) const
bool | ReadParameter (std::vector< std::string > &parameterValues, const std::string &parameterName, const unsigned int entry_nr_start, const unsigned int entry_nr_end, const bool produceWarningMessage, std::string &warningMessage) const
template<class T>
bool | ReadParameter (std::vector< T > &parameterValues, const std::string &parameterName, const unsigned int entry_nr_start, const unsigned int entry_nr_end, const bool produceWarningMessage, std::string &warningMessage) const
template<class T>
bool | ReadParameter (T &parameterValue, const std::string &parameterName, const std::string &prefix, const unsigned int entry_nr, const int default_entry_nr, const bool produceWarningMessage, std::string &warningMessage) const
template<class T>
bool | ReadParameter (T &parameterValue, const std::string &parameterName, const std::string &prefix, const unsigned int entry_nr, const unsigned int default_entry_nr, std::string &warningMessage) const
template<class T>
bool | ReadParameter (T &parameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool produceWarningMessage, std::string &warningMessage) const
template<class T>
bool | ReadParameter (T &parameterValue, const std::string &parameterName, const unsigned int entry_nr, std::string &warningMessage) const
template<typename T>
std::unique_ptr< std::vector< T > > | RetrieveValues (const std::string &parameterName) const
void | SetParameterMap (const ParameterMapType &parMap)
virtual void | SetPrintErrorMessages (bool _arg)

## Static Public Member Functions

static Pointer | New ()

## Protected Member Functions

| ParameterMapInterface ()
| ~ParameterMapInterface () override

## Private Attributes

ParameterMapType | m_ParameterMap {}
bool | m_PrintErrorMessages { true }

## Member Typedef Documentation

## ConstPointer

using itk::ParameterMapInterface::ConstPointer = SmartPointer<const Self>

Definition at line 87 of file itkParameterMapInterface.h.

## ParameterMapType

using itk::ParameterMapInterface::ParameterMapType = ParameterFileParser::ParameterMapType

Definition at line 97 of file itkParameterMapInterface.h.

## ParameterValuesType

using itk::ParameterMapInterface::ParameterValuesType = ParameterFileParser::ParameterValuesType

Typedefs.

Definition at line 96 of file itkParameterMapInterface.h.

## Pointer

using itk::ParameterMapInterface::Pointer = SmartPointer<Self>

Definition at line 86 of file itkParameterMapInterface.h.

## Self

using itk::ParameterMapInterface::Self = ParameterMapInterface

Standard ITK typedefs.

Definition at line 84 of file itkParameterMapInterface.h.

## Superclass

using itk::ParameterMapInterface::Superclass = Object

Definition at line 85 of file itkParameterMapInterface.h.

## Constructor & Destructor Documentation

## ParameterMapInterface()

itk::ParameterMapInterface::ParameterMapInterface | ( |  | ) |

protected

## ~ParameterMapInterface()

itk::ParameterMapInterface::~ParameterMapInterface | ( |  | ) |

override protected

## Member Function Documentation

## CountNumberOfParameterEntries()

std::vcl_size_t itk::ParameterMapInterface::CountNumberOfParameterEntries | ( | const std::string & | parameterName | ) | const

Get the number of entries for a given parameter.

## GetClassName()

virtual const char * itk::ParameterMapInterface::GetClassName | ( |  | ) | const

virtual

Run-time type information (and related methods).

## GetPrintErrorMessages()

virtual bool itk::ParameterMapInterface::GetPrintErrorMessages | ( |  | ) | const

virtual

## GetValues()

std::vector< std::string > itk::ParameterMapInterface::GetValues | ( | const std::string & | parameterName | ) | const

inline

Returns the values of the specified parameter.

Definition at line 374 of file itkParameterMapInterface.h.

## HasParameter()

bool itk::ParameterMapInterface::HasParameter | ( | const std::string & | parameterName | ) | const

inline

Tells whether this parameter map has the parameter with the given name.

Definition at line 113 of file itkParameterMapInterface.h.

## ITK_DISALLOW_COPY_AND_MOVE()

itk::ParameterMapInterface::ITK_DISALLOW_COPY_AND_MOVE | ( | ParameterMapInterface |  | ) |

## New()

Pointer itk::ParameterMapInterface::New | ( |  | ) |

static

Method for creation through the object factory.

## ReadParameter() [1/7]

bool itk::ParameterMapInterface::ReadParameter | ( | bool & | parameterValue,
|  | const std::string & | parameterName,
|  | const unsigned int | entry_nr,
|  | const bool | produceWarningMessage,
|  | std::string & | warningMessage ) const

Boolean support.

## ReadParameter() [2/7]

bool itk::ParameterMapInterface::ReadParameter | ( | std::vector< std::string > & | parameterValues,
|  | const std::string & | parameterName,
|  | const unsigned int | entry_nr_start,
|  | const unsigned int | entry_nr_end,
|  | const bool | produceWarningMessage,
|  | std::string & | warningMessage ) const

Provide a specialization for std::string, for efficiency.

## ReadParameter() [3/7]

template<class T>

bool itk::ParameterMapInterface::ReadParameter | ( | std::vector< T > & | parameterValues,
|  | const std::string & | parameterName,
|  | const unsigned int | entry_nr_start,
|  | const unsigned int | entry_nr_end,
|  | const bool | produceWarningMessage,
|  | std::string & | warningMessage ) const

inline

An extended version that reads all parameters in a range at once.

Definition at line 287 of file itkParameterMapInterface.h.

## ReadParameter() [4/7]

template<class T>

bool itk::ParameterMapInterface::ReadParameter | ( | T & | parameterValue,
|  | const std::string & | parameterName,
|  | const std::string & | prefix,
|  | const unsigned int | entry_nr,
|  | const int | default_entry_nr,
|  | const bool | produceWarningMessage,
|  | std::string & | warningMessage ) const

inline

An extended version of ReadParameter() that takes prefixes and default entry numbers (for convenience). This function tries to read parameterName, but also prefix+parameterName. Also, multiple entries are tried, entry_nr as well as default_entry_nr.

Definition at line 227 of file itkParameterMapInterface.h.

## ReadParameter() [5/7]

template<class T>

bool itk::ParameterMapInterface::ReadParameter | ( | T & | parameterValue,
|  | const std::string & | parameterName,
|  | const std::string & | prefix,
|  | const unsigned int | entry_nr,
|  | const unsigned int | default_entry_nr,
|  | std::string & | warningMessage ) const

inline

A shorter version of the extended ReadParameter() that does not require the boolean produceWarningMessage. Instead the default value true is used.

Definition at line 273 of file itkParameterMapInterface.h.

## ReadParameter() [6/7]

template<class T>

bool itk::ParameterMapInterface::ReadParameter | ( | T & | parameterValue,
|  | const std::string & | parameterName,
|  | const unsigned int | entry_nr,
|  | const bool | produceWarningMessage,
|  | std::string & | warningMessage ) const

inline

Get the desired parameter from the parameter map as type T.

When requesting to read a parameter, multiple scenarios exist: 1) The parameter is not found at all 2) The parameter is found, but index entry_nr does not exist 3) The parameter is found at the requested index, and cast is correct 4) The parameter is found at the requested index, but the cast fails What to return for these three options? 1) -> return false + warning if desired 2) -> return false + other warning if desired 3) -> return true and no warning 4) -> Throw exception: there is an error in the parameter file

Definition at line 138 of file itkParameterMapInterface.h.

## ReadParameter() [7/7]

template<class T>

bool itk::ParameterMapInterface::ReadParameter | ( | T & | parameterValue,
|  | const std::string & | parameterName,
|  | const unsigned int | entry_nr,
|  | std::string & | warningMessage ) const

inline

A shorter version of ReadParameter() that does not require the boolean produceWarningMessage. Instead the default value true is used.

Definition at line 211 of file itkParameterMapInterface.h.

## RetrieveValues()

template<typename T>

std::unique_ptr< std::vector< T > > itk::ParameterMapInterface::RetrieveValues | ( | const std::string & | parameterName | ) | const

inline

Retrieves the values of the specified parameter. Returns null when the map does not contain the specified parameter. Throws an exception when it fails to convert each of the values to the specified type T.

Definition at line 386 of file itkParameterMapInterface.h.

## SetParameterMap()

void itk::ParameterMapInterface::SetParameterMap | ( | const ParameterMapType & | parMap | ) |

Set the parameter map.

## SetPrintErrorMessages()

virtual void itk::ParameterMapInterface::SetPrintErrorMessages | ( | bool | _arg | ) |

virtual

Option to print error and warning messages to a stream. The default is true. If set to false no messages are printed.

## Field Documentation

## m_ParameterMap

ParameterMapType itk::ParameterMapInterface::m_ParameterMap {}

private

Member variable to store the parameters.

Definition at line 422 of file itkParameterMapInterface.h.

## m_PrintErrorMessages

bool itk::ParameterMapInterface::m_PrintErrorMessages { true }

private

Definition at line 424 of file itkParameterMapInterface.h.

Generated on 1768596610 for elastix by 1.15.0 |