Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages |
#include <itkParameterMapInterface.h>
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.
Definition at line 73 of file itkParameterMapInterface.h.
Public Types | |
typedef SmartPointer< const Self > | ConstPointer |
typedef ParameterFileParser::ParameterMapType | ParameterMapType |
typedef ParameterFileParser::ParameterValuesType | ParameterValuesType |
typedef SmartPointer< Self > | Pointer |
typedef ParameterMapInterface | Self |
typedef Object | Superclass |
Public Member Functions | |
std::vcl_size_t | CountNumberOfParameterEntries (const std::string ¶meterName) const |
virtual const char * | GetClassName () const |
virtual bool | GetPrintErrorMessages () const |
bool | ReadParameter (bool ¶meterValue, const std::string ¶meterName, const unsigned int entry_nr, const bool printThisErrorMessage, std::string &errorMessage) const |
bool | ReadParameter (std::vector< std::string > ¶meterValues, const std::string ¶meterName, 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 > ¶meterValues, const std::string ¶meterName, 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 ¶meterValue, const std::string ¶meterName, 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 ¶meterValue, const std::string ¶meterName, 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 ¶meterValue, const std::string ¶meterName, const unsigned int entry_nr, const bool printThisErrorMessage, std::string &errorMessage) const |
template<class T > | |
bool | ReadParameter (T ¶meterValue, const std::string ¶meterName, 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 ¶meterValue, std::string &casted) const |
template<class T > | |
bool | StringCast (const std::string ¶meterValue, T &casted) const |
Private Attributes | |
ParameterMapType | m_ParameterMap |
bool | m_PrintErrorMessages |
typedef SmartPointer< const Self > itk::ParameterMapInterface::ConstPointer |
Definition at line 81 of file itkParameterMapInterface.h.
Definition at line 91 of file itkParameterMapInterface.h.
Typedefs.
Definition at line 90 of file itkParameterMapInterface.h.
typedef SmartPointer< Self > itk::ParameterMapInterface::Pointer |
Definition at line 80 of file itkParameterMapInterface.h.
Standard ITK typedefs.
Definition at line 78 of file itkParameterMapInterface.h.
typedef Object itk::ParameterMapInterface::Superclass |
Definition at line 79 of file itkParameterMapInterface.h.
|
protected |
|
overrideprotected |
|
private |
std::vcl_size_t itk::ParameterMapInterface::CountNumberOfParameterEntries | ( | const std::string & | parameterName | ) | const |
Get the number of entries for a given parameter.
|
virtual |
Run-time type information (and related methods).
|
virtual |
|
static |
Method for creation through the object factory.
|
private |
bool itk::ParameterMapInterface::ReadParameter | ( | bool & | parameterValue, |
const std::string & | parameterName, | ||
const unsigned int | entry_nr, | ||
const bool | printThisErrorMessage, | ||
std::string & | errorMessage | ||
) | const |
Boolean support.
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.
|
inline |
An extended version that reads all parameters in a range at once.
Definition at line 287 of file itkParameterMapInterface.h.
|
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.
|
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.
|
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.
|
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.
void itk::ParameterMapInterface::SetParameterMap | ( | const ParameterMapType & | parMap | ) |
Set the parameter map.
|
virtual |
Option to print error and warning messages to a stream. The default is true. If set to false no messages are printed.
|
private |
Provide a specialization for std::string, since the general StringCast (especially ss >> casted) will not work for strings containing spaces.
|
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.
|
private |
Member variable to store the parameters.
Definition at line 398 of file itkParameterMapInterface.h.
|
private |
Definition at line 400 of file itkParameterMapInterface.h.
Generated on 1667476801 for elastix by 1.9.4 |