blockfactory  0.8
A framework for wrapping algorithms for dataflow programming
blockfactory::core::Parameters Class Reference

Class for storing block's parameters. More...

#include <Parameters.h>

Detailed Description

Class for storing block's parameters.

This class can contain scalar and vector parameters of the supported types.

See also
core::Parameter, core::ParameterMetadata, core::ParameterType

Public Types

using ParamIndex = int
 
using ParamName = std::string
 

Public Member Functions

 Parameters ()
 
 Parameters (const blockfactory::core::Parameters &other)
 
Parametersoperator= (const Parameters &other)
 
 ~Parameters ()
 
ParamName getParamName (const ParamIndex &index) const
 Get the name of a stored parameter from its index. More...
 
ParamIndex getParamIndex (const ParamName &name) const
 Get the index of a stored parameter from its name. More...
 
unsigned getNumberOfParameters () const
 Get the number of stored parameters. More...
 
bool existName (const ParamName &name) const
 Check if a parameter with a given name is stored. More...
 
template<typename T >
bool storeParameter (const T &param, const blockfactory::core::ParameterMetadata &paramMetadata)
 Store a scalar parameter. More...
 
template<typename T >
bool storeParameter (const std::vector< T > &param, const blockfactory::core::ParameterMetadata &paramMetadata)
 Store a vector parameter. More...
 
template<typename T >
bool storeParameter (const Parameter< T > &parameter)
 Store a parameter. More...
 
template<typename T >
bool getParameter (const ParamName &name, T &param) const
 Get a scalar parameter. More...
 
template<typename T >
bool getParameter (const ParamName &name, std::vector< T > &param) const
 Get a vector parameter. More...
 
std::vector< Parameter< int > > getIntParameters () const
 Get all the integer parameters. More...
 
std::vector< Parameter< bool > > getBoolParameters () const
 Get all the boolean parameters. More...
 
std::vector< Parameter< double > > getDoubleParameters () const
 Get all the double parameters. More...
 
std::vector< Parameter< std::string > > getStringParameters () const
 Get all the string parameters. More...
 
blockfactory::core::ParameterMetadata getParameterMetadata (const ParamName &name)
 Get the metadata associated to a stored parameter. More...
 

Member Typedef Documentation

Constructor & Destructor Documentation

blockfactory::core::Parameters::Parameters ( )
blockfactory::core::Parameters::Parameters ( const blockfactory::core::Parameters other)
blockfactory::core::Parameters::~Parameters ( )

Member Function Documentation

bool blockfactory::core::Parameters::existName ( const ParamName name) const

Check if a parameter with a given name is stored.

Parameters
nameThe name of the parameter.
Returns
True if the parameters exists, false otherwise.
std::vector<Parameter<bool> > blockfactory::core::Parameters::getBoolParameters ( ) const

Get all the boolean parameters.

Returns
The boolean parameters
std::vector<Parameter<double> > blockfactory::core::Parameters::getDoubleParameters ( ) const

Get all the double parameters.

Returns
The double parameters
std::vector<Parameter<int> > blockfactory::core::Parameters::getIntParameters ( ) const

Get all the integer parameters.

Returns
The integer parameters
unsigned blockfactory::core::Parameters::getNumberOfParameters ( ) const

Get the number of stored parameters.

Returns
The number of stored parameters.
template<typename T >
bool blockfactory::core::Parameters::getParameter ( const ParamName name,
T &  param 
) const

Get a scalar parameter.

Template Parameters
Thetype of the output argument
Parameters
nameThe name of the parameter.
[out]paramThe variable where the parameter value will be stored. Data get cast internally, even for string to numeric types.
Returns
True for success, false otherwise.
template<typename T >
bool blockfactory::core::Parameters::getParameter ( const ParamName name,
std::vector< T > &  param 
) const

Get a vector parameter.

Template Parameters
Thetype of the output argument
Parameters
nameThe name of the parameter.
[out]paramThe variable where the parameter value will be stored. Data get cast internally, even for string to numeric types.
Returns
True for success, false otherwise.
blockfactory::core::ParameterMetadata blockfactory::core::Parameters::getParameterMetadata ( const ParamName name)

Get the metadata associated to a stored parameter.

Parameters
nameThe name of the parameter.
Returns
The metadata associate with the parameter for success, a metadata with a stored name dummy otherwise.
Todo:
Use std::optional as soon as we switch to C++17
ParamIndex blockfactory::core::Parameters::getParamIndex ( const ParamName name) const

Get the index of a stored parameter from its name.

Parameters
nameThe name of the parameter.
Returns
The index if the parameter exists, core::PARAM_INVALID_INDEX otherwise.
ParamName blockfactory::core::Parameters::getParamName ( const ParamIndex index) const

Get the name of a stored parameter from its index.

Parameters
indexThe index of the parameter.
Returns
The name if the parameter exists, core::PARAM_INVALID_NAME otherwise.
std::vector<Parameter<std::string> > blockfactory::core::Parameters::getStringParameters ( ) const

Get all the string parameters.

Returns
The string parameters
Parameters& blockfactory::core::Parameters::operator= ( const Parameters other)
template<typename T >
bool blockfactory::core::Parameters::storeParameter ( const T &  param,
const blockfactory::core::ParameterMetadata paramMetadata 
)

Store a scalar parameter.

Template Parameters
Thetype of the parameter to store. Despite this, the parameter get cast accordingly to its metadata.
Parameters
paramThe value of the scalar parameter to store.
paramMetadataThe metadata associated to the parameter to store.
Returns
True for success, false otherwise.
template<typename T >
bool blockfactory::core::Parameters::storeParameter ( const std::vector< T > &  param,
const blockfactory::core::ParameterMetadata paramMetadata 
)

Store a vector parameter.

Template Parameters
Thetype of the parameter to store. Despite this, the parameter get cast accordingly to its metadata.
Parameters
paramThe value of the vector parameter to store.
paramMetadataThe metadata associated to the parameter to store.
Returns
True for success, false otherwise.
template<typename T >
bool blockfactory::core::Parameters::storeParameter ( const Parameter< T > &  parameter)

Store a parameter.

Template Parameters
Thetype of the parameter to store.
Parameters
parameterThe parameter object to store.
Returns
True for success, false otherwise.
See also
wbt::Parameter

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