go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
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 errorMessage = ""; bool success = p_interface->ReadParameter( parameterValue, "ParameterName", index, printWarning, errorMessage );

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 73 of file itkParameterMapInterface.h.

+ Inheritance diagram for itk::ParameterMapInterface:

Public Types

typedef SmartPointer< const SelfConstPointer
 
typedef ParameterFileParser::ParameterMapType ParameterMapType
 
typedef ParameterFileParser::ParameterValuesType ParameterValuesType
 
typedef SmartPointer< SelfPointer
 
typedef ParameterMapInterface Self
 
typedef Object Superclass
 

Public Member Functions

std::vcl_size_t CountNumberOfParameterEntries (const std::string &parameterName) const
 
virtual const char * GetClassName () const
 
virtual bool GetPrintErrorMessages () const
 
bool ReadParameter (bool &parameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool printThisErrorMessage, std::string &errorMessage) 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 printThisErrorMessage, std::string &errorMessage) 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 printThisErrorMessage, std::string &errorMessage) 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 printThisErrorMessage, std::string &errorMessage) 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 &errorMessage) const
 
template<class T >
bool ReadParameter (T &parameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool printThisErrorMessage, std::string &errorMessage) const
 
template<class T >
bool ReadParameter (T &parameterValue, const std::string &parameterName, const unsigned int entry_nr, std::string &errorMessage) 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 Member Functions

void operator= (const Self &)
 
 ParameterMapInterface (const Self &)
 
bool StringCast (const std::string &parameterValue, std::string &casted) const
 
template<class T >
bool StringCast (const std::string &parameterValue, T &casted) const
 

Private Attributes

ParameterMapType m_ParameterMap
 
bool m_PrintErrorMessages
 

Member Typedef Documentation

◆ ConstPointer

typedef SmartPointer< const Self > itk::ParameterMapInterface::ConstPointer

Definition at line 81 of file itkParameterMapInterface.h.

◆ ParameterMapType

Definition at line 91 of file itkParameterMapInterface.h.

◆ ParameterValuesType

Typedefs.

Definition at line 90 of file itkParameterMapInterface.h.

◆ Pointer

typedef SmartPointer< Self > itk::ParameterMapInterface::Pointer

Definition at line 80 of file itkParameterMapInterface.h.

◆ Self

Standard ITK typedefs.

Definition at line 78 of file itkParameterMapInterface.h.

◆ Superclass

Definition at line 79 of file itkParameterMapInterface.h.

Constructor & Destructor Documentation

◆ ParameterMapInterface() [1/2]

itk::ParameterMapInterface::ParameterMapInterface ( )
protected

◆ ~ParameterMapInterface()

itk::ParameterMapInterface::~ParameterMapInterface ( )
overrideprotected

◆ ParameterMapInterface() [2/2]

itk::ParameterMapInterface::ParameterMapInterface ( const Self )
private

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

◆ New()

static Pointer itk::ParameterMapInterface::New ( )
static

Method for creation through the object factory.

◆ operator=()

void itk::ParameterMapInterface::operator= ( const Self )
private

◆ ReadParameter() [1/7]

bool itk::ParameterMapInterface::ReadParameter ( bool parameterValue,
const std::string &  parameterName,
const unsigned int  entry_nr,
const bool  printThisErrorMessage,
std::string &  errorMessage 
) 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  printThisErrorMessage,
std::string &  errorMessage 
) 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  printThisErrorMessage,
std::string &  errorMessage 
) 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  printThisErrorMessage,
std::string &  errorMessage 
) 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 220 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 &  errorMessage 
) const
inline

A shorter version of the extended ReadParameter() that does not require the boolean printThisErrorMessage. 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  printThisErrorMessage,
std::string &  errorMessage 
) 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 123 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 &  errorMessage 
) const
inline

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

Definition at line 204 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.

◆ StringCast() [1/2]

bool itk::ParameterMapInterface::StringCast ( const std::string &  parameterValue,
std::string &  casted 
) const
private

Provide a specialization for std::string, since the general StringCast (especially ss >> casted) will not work for strings containing spaces.

◆ StringCast() [2/2]

template<class T >
bool itk::ParameterMapInterface::StringCast ( const std::string &  parameterValue,
T &  casted 
) const
inlineprivate

A templated function to cast strings to a type T. Returns true when casting was successful and false otherwise. We make use of the casting functionality of string streams.

Definition at line 407 of file itkParameterMapInterface.h.

Field Documentation

◆ m_ParameterMap

ParameterMapType itk::ParameterMapInterface::m_ParameterMap
private

Member variable to store the parameters.

Definition at line 398 of file itkParameterMapInterface.h.

◆ m_PrintErrorMessages

bool itk::ParameterMapInterface::m_PrintErrorMessages
private

Definition at line 400 of file itkParameterMapInterface.h.



Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo