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.
|
std::vcl_size_t | CountNumberOfParameterEntries (const std::string ¶meterName) const |
|
virtual const char * | GetClassName () const |
|
virtual bool | GetPrintErrorMessages () const |
|
std::vector< std::string > | GetValues (const std::string ¶meterName) const |
|
bool | HasParameter (const std::string ¶meterName) const |
|
| ITK_DISALLOW_COPY_AND_MOVE (ParameterMapInterface) |
|
bool | ReadParameter (bool ¶meterValue, const std::string ¶meterName, const unsigned int entry_nr, const bool produceWarningMessage, std::string &warningMessage) 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 produceWarningMessage, std::string &warningMessage) 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 produceWarningMessage, std::string &warningMessage) 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 produceWarningMessage, std::string &warningMessage) 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 &warningMessage) const |
|
template<class T > |
bool | ReadParameter (T ¶meterValue, const std::string ¶meterName, const unsigned int entry_nr, const bool produceWarningMessage, std::string &warningMessage) const |
|
template<class T > |
bool | ReadParameter (T ¶meterValue, const std::string ¶meterName, const unsigned int entry_nr, std::string &warningMessage) const |
|
template<typename T > |
std::unique_ptr< std::vector< T > > | RetrieveValues (const std::string ¶meterName) const |
|
void | SetParameterMap (const ParameterMapType &parMap) |
|
virtual void | SetPrintErrorMessages (bool _arg) |
|
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.