Stores parameters in an internal map, which associates a names with its value.
More...
#include <mknn_params.hpp>
|
std::unique_ptr< Impl > | pimpl |
| opaque object
|
|
|
class | Distance |
|
class | PredefDistance |
|
Stores parameters in an internal map, which associates a names with its value.
The internal map only stores two type of objects: strings and void pointers. The getter and setter methods that use integer/double/boolean actually convert them to/from a string.
void mknn::DistanceParams::addBool |
( |
std::string |
name, |
|
|
bool |
value |
|
) |
| |
Adds an boolean value to the parameters.
A copy of name
is stored in params
.
- Parameters
-
name | the name of the parameter. |
value | the value of the parameter. |
void mknn::DistanceParams::addDouble |
( |
std::string |
name, |
|
|
double |
value |
|
) |
| |
Adds a floating point number to the parameters.
A copy of name
is stored in params
.
- Parameters
-
name | the name of the parameter. |
value | the value of the parameter. |
void mknn::DistanceParams::addInt |
( |
std::string |
name, |
|
|
long long |
value |
|
) |
| |
Adds an integer number to the parameters.
A copy of name
is stored in params
.
- Parameters
-
name | the name of the parameter. |
value | the value of the parameter. |
void mknn::DistanceParams::addObject |
( |
std::string |
name, |
|
|
void * |
value |
|
) |
| |
Adds an object number to the parameters.
A copy of name
is stored in params
but the value pointer itself is stored in params
. Therefore the value
pointer must remain valid during all the lifetime of params
.
- Parameters
-
name | the name of the parameter. |
value | the value of the parameter. |
void mknn::DistanceParams::addString |
( |
std::string |
name, |
|
|
std::string |
value |
|
) |
| |
Adds a string to the parameters.
A copy of name
and value
are stored in params
.
- Parameters
-
name | the name of the parameter. |
value | the value of the parameter. |
Copies all the key-values pairs in params_from
and adds them to params_to
.
- Parameters
-
params_from | the parameters from which the values are read. |
bool mknn::DistanceParams::getBool |
( |
std::string |
name | ) |
|
Returns a boolean value.
- Parameters
-
name | the name of the parameter. |
- Returns
- the stored value. If the stored value is not a boolean value, it will raise an error.
std::string mknn::DistanceParams::getDistanceId |
( |
| ) |
|
double mknn::DistanceParams::getDouble |
( |
std::string |
name | ) |
|
Returns a floating-point number.
- Parameters
-
name | the name of the parameter. |
- Returns
- the stored number. If the stored value is not a number, it will raise an error.
long long mknn::DistanceParams::getInt |
( |
std::string |
name | ) |
|
Returns an integer number.
- Parameters
-
name | the name of the parameter. |
- Returns
- the stored number. If the stored value is not a number, it will raise an error.
void* mknn::DistanceParams::getObject |
( |
std::string |
name | ) |
|
Returns a object reference.
- Parameters
-
name | the name of the parameter. |
- Returns
- a pointer to the stored object.
std::string mknn::DistanceParams::getString |
( |
std::string |
name | ) |
|
Returns a string value.
- Parameters
-
name | the name of the parameter. |
- Returns
- a pointer to the stored string (it must not be modified).
Creates an empty object.
- Returns
- a new empty object.
static DistanceParams mknn::DistanceParams::newParseString |
( |
std::string |
parameters_string | ) |
|
|
static |
Creates an empty object and set parameters by calling method parseString.
- Parameters
-
parameters_string | the string with parameters. |
- Returns
- a parameters object
void mknn::DistanceParams::parseString |
( |
std::string |
parameters_string | ) |
|
Parses a string in the format: ID_DISTANCE,parameter1=value1,parameter2=value2
Each parsed parameter is added to params
.
For example:
LP,order=0.5
DPF,order=1,pct_discard=0.1
The list of valid IDs can be listed by invoking PredefDistance::helpListDistances.
- Parameters
-
parameters_string | the string with parameters. |
void mknn::DistanceParams::setDistanceId |
( |
std::string |
id_dist | ) |
|
std::string mknn::DistanceParams::toString |
( |
| ) |
|
Returns a string with the parameters which can be parsed.
- Returns
- a string representation of parameters.
The documentation for this class was generated from the following file: