VisionWorks Toolkit Reference

December 18, 2015 | 1.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvxio::OptionHandler Class Referenceabstract

Detailed Description

OptionHandler interface.

This class is an interface supplying a mechanism for processing an option and human-readable information about that option.

See also
NVXIO APIs

Definition at line 50 of file OptionHandler.hpp.

Public Types

typedef std::unique_ptr
< OptionHandler
ptr
 

Public Member Functions

virtual std::string getConstraintString () const
 Gets information about valid values of the option. More...
 
virtual std::string getDefaultString () const =0
 Gets the default value of the option. More...
 
virtual std::string getPlaceholder () const =0
 Gets a short hint that describes the expected values of the option (i.e., a placeholder for the option). More...
 
virtual std::string processValue (const std::string &valueStr) const =0
 Processes the value of the option. More...
 
virtual ~OptionHandler ()
 

Static Public Member Functions

static ptr integer (int *result, const Range< int > &validRange=ranges::all< int >())
 Creates an option handler that accepts argument values that look like decimal integers, converts them to int, and then stores them in the provided variable. More...
 
static ptr oneOf (std::string *result, std::initializer_list< std::string > allowedValues)
 Creates an option handler that accepts argument values from a certain set and stores them in the provided variable. More...
 
template<typename T >
static ptr oneOf (T *result, typename PairList< T >::type allowedValues)
 Creates an option handler that accepts an argument value from a certain set, maps the argument value to a value of type T, and then stores that value in the provided variable. More...
 
static ptr real (float *result, const Range< float > &validRange=ranges::all< float >())
 Creates an option handler that accepts argument values that look like real numbers, converts them to float, and then stores them in the provided variable. More...
 
static ptr real (double *result, const Range< double > &validRange=ranges::all< double >())
 Creates an option handler that accepts argument values that look like real numbers, converts them to double, and then stores them in the provided variable. More...
 
static ptr string (std::string *result)
 Creates an option handler that accepts any argument value and copies it verbatim to the provided variable. More...
 
static ptr unsignedInteger (unsigned *result, const Range< unsigned > &validRange=ranges::all< unsigned >())
 Creates an option handler that accepts argument values that look like unsigned decimal integers, converts them to unsigned int, and then stores them in the provided variable. More...
 

Member Typedef Documentation

typedef std::unique_ptr<OptionHandler> nvxio::OptionHandler::ptr

Definition at line 59 of file OptionHandler.hpp.

Constructor & Destructor Documentation

virtual nvxio::OptionHandler::~OptionHandler ( )
virtual

Member Function Documentation

virtual std::string nvxio::OptionHandler::getPlaceholder ( ) const
pure virtual

Gets a short hint that describes the expected values of the option (i.e., a placeholder for the option).

Returns
Placeholder for the option.
virtual std::string nvxio::OptionHandler::getConstraintString ( ) const
virtual

Gets information about valid values of the option.

Returns
Information about valid values of the option.
virtual std::string nvxio::OptionHandler::getDefaultString ( ) const
pure virtual

Gets the default value of the option.

Returns
Default value of the option.
virtual std::string nvxio::OptionHandler::processValue ( const std::string &  valueStr) const
pure virtual

Processes the value of the option.

Parameters
[in]valueStrA reference to the value of the option.
Returns
Status of the operation. If the operation fails returns an error message and an empty string.
static ptr nvxio::OptionHandler::string ( std::string *  result)
static

Creates an option handler that accepts any argument value and copies it verbatim to the provided variable.

Parameters
[in,out]resultA pointer to the provided variable that corresponds to the option.
Returns
A pointer to the OptionHandler.
Example Code
std::string configFile = "config.ini";
app.addOption('c', "config", "Config file path", nvxio::OptionHandler::string(&configFile));
static ptr nvxio::OptionHandler::integer ( int *  result,
const Range< int > &  validRange = ranges::all< int >() 
)
static

Creates an option handler that accepts argument values that look like decimal integers, converts them to int, and then stores them in the provided variable.

Parameters
[in,out]resultA pointer to the provided variable that corresponds to the option.
[in]validRangeA reference to a range of valid values of the option.
Returns
A pointer to the OptionHandler.
Example Code
int numOfPoints;
app.addOption('n', "numOfPoints", "Number of feature points", nvxio::OptionHandler::integer(&numOfPoints));
static ptr nvxio::OptionHandler::unsignedInteger ( unsigned *  result,
const Range< unsigned > &  validRange = ranges::all< unsigned >() 
)
static

Creates an option handler that accepts argument values that look like unsigned decimal integers, converts them to unsigned int, and then stores them in the provided variable.

Parameters
[in,out]resultA pointer to the provided variable that corresponds to the option.
[in]validRangeA reference to a range of valid values of the option.
Returns
A pointer to the OptionHandler.
static ptr nvxio::OptionHandler::real ( float *  result,
const Range< float > &  validRange = ranges::all< float >() 
)
static

Creates an option handler that accepts argument values that look like real numbers, converts them to float, and then stores them in the provided variable.

Parameters
[in,out]resultA pointer to the provided variable that corresponds to the option.
[in]validRangeA range of valid values of the option.
Returns
A pointer to the OptionHandler.
static ptr nvxio::OptionHandler::real ( double *  result,
const Range< double > &  validRange = ranges::all< double >() 
)
static

Creates an option handler that accepts argument values that look like real numbers, converts them to double, and then stores them in the provided variable.

Parameters
[in,out]resultA pointer to the provided variable that corresponds to the option.
[in]validRangeA reference to a range of valid values of the option.
Returns
A pointer to the OptionHandler.
static ptr nvxio::OptionHandler::oneOf ( std::string *  result,
std::initializer_list< std::string >  allowedValues 
)
static

Creates an option handler that accepts argument values from a certain set and stores them in the provided variable.

Parameters
[in,out]resultA pointer to the provided variable that corresponds to the option.
[in]allowedValuesThe set of allowed values.
Returns
A pointer to the OptionHandler.
Example Code
std::string mode = "pedestrians";
app.addOption(0, "mode", "Detector mode", nvxio::OptionHandler::oneOf(&mode, {"pedestrians", "cars"}));
template<typename T >
static ptr nvxio::OptionHandler::oneOf ( T *  result,
typename PairList< T >::type  allowedValues 
)
static

Creates an option handler that accepts an argument value from a certain set, maps the argument value to a value of type T, and then stores that value in the provided variable.

Parameters
[in,out]resultA pointer to the provided variable that corresponds to the option.
[in]allowedValuesThe set of allowed values. The set consists of combinations of a key value (std::string) and a mapped value that has a type T.
Returns
A pointer to the OptionHandler.
Example Code
vx_enum scaleType = 0;
app.addOption(0, "scaleType", "[ScaleImage] The scale interpolation type",
{"nearest", 0},
{"bilinear", 1},
{"area", 2},
}));

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