Loading...
Searching...
No Matches
ompl::base::ParamSet Class Reference

Maintain a set of parameters. More...

#include <ompl/base/GenericParam.h>

Public Member Functions

template<typename T >
void declareParam (const std::string &name, const typename SpecificParam< T >::SetterFn &setter, const typename SpecificParam< T >::GetterFn &getter=[] { return T();})
 This function declares a parameter name, and specifies the setter and getter functions.
 
void add (const GenericParamPtr &param)
 Add a parameter to the set.
 
void remove (const std::string &name)
 Remove a parameter from the set.
 
void include (const ParamSet &other, const std::string &prefix="")
 Include the params of a different ParamSet into this one. Optionally include a prefix for each of the parameters.
 
bool setParam (const std::string &key, const std::string &value)
 Algorithms in OMPL often have parameters that can be set externally. While each algorithm will have their own getter and setter functions specifically for those parameters, this function allows setting parameters generically, for any algorithm that declares parameters, by specifying the parameter name key and its value value (both as string, but value is cast to the type desired by the corresponding setter). Under the hood, this calls SpecificParam::setValue(). This ability makes it easy to automatically configure using external sources (e.g., a configuration file). The function returns true if the parameter was parsed and set successfully and false otherwise.
 
bool getParam (const std::string &key, std::string &value) const
 Get the value of the parameter named key. Store the value as string in value and return true if the parameter was found. Return false otherwise.
 
bool setParams (const std::map< std::string, std::string > &kv, bool ignoreUnknown=false)
 Set the values for a set of parameters. The parameter names are the keys in the map kv. The corresponding key values in kv are set as the parameter values. Return true if all parameters were set successfully. This function simply calls setParam() multiple times. If ignoreUnknown is true, then no attempt is made to set unknown parameters (and thus no errors are reported)
 
void getParams (std::map< std::string, std::string > &params) const
 Get the known parameter as a map from names to their values cast as string.
 
void getParamNames (std::vector< std::string > &params) const
 List the names of the known parameters.
 
void getParamValues (std::vector< std::string > &vals) const
 List the values of the known parameters, in the same order as getParamNames()
 
const std::map< std::string, GenericParamPtr > & getParams () const
 Get the map from parameter names to parameter descriptions.
 
const GenericParamPtr & getParam (const std::string &key) const
 Get the parameter that corresponds to a specified name. An empty shared ptr is returned if the parameter does not exist.
 
bool hasParam (const std::string &key) const
 Check whether this set of parameters includes the parameter named key.
 
GenericParamoperator[] (const std::string &key)
 Access operator for parameters, by name. If the parameter is not defined, an exception is thrown.
 
std::size_t size () const
 Get the number of parameters maintained by this instance.
 
void clear ()
 Clear all the set parameters.
 
void print (std::ostream &out) const
 Print the parameters to a stream.
 

Detailed Description

Maintain a set of parameters.

Definition at line 225 of file GenericParam.h.

Member Function Documentation

◆ add()

void ompl::base::ParamSet::add ( const GenericParamPtr & param)

Add a parameter to the set.

Definition at line 209 of file GenericParam.cpp.

◆ clear()

void ompl::base::ParamSet::clear ( )

Clear all the set parameters.

Definition at line 219 of file GenericParam.cpp.

◆ declareParam()

template<typename T >
void ompl::base::ParamSet::declareParam ( const std::string & name,
const typename SpecificParam< T >::SetterFn & setter,
const typename SpecificParam< T >::GetterFn & getter = [] { return T(); } )
inline

This function declares a parameter name, and specifies the setter and getter functions.

Definition at line 231 of file GenericParam.h.

◆ getParam() [1/2]

const ompl::base::GenericParamPtr & ompl::base::ParamSet::getParam ( const std::string & key) const

Get the parameter that corresponds to a specified name. An empty shared ptr is returned if the parameter does not exist.

Definition at line 171 of file GenericParam.cpp.

◆ getParam() [2/2]

bool ompl::base::ParamSet::getParam ( const std::string & key,
std::string & value ) const

Get the value of the parameter named key. Store the value as string in value and return true if the parameter was found. Return false otherwise.

Definition at line 138 of file GenericParam.cpp.

◆ getParamNames()

void ompl::base::ParamSet::getParamNames ( std::vector< std::string > & params) const

List the names of the known parameters.

Definition at line 149 of file GenericParam.cpp.

◆ getParams() [1/2]

const std::map< std::string, ompl::base::GenericParamPtr > & ompl::base::ParamSet::getParams ( ) const

Get the map from parameter names to parameter descriptions.

Definition at line 166 of file GenericParam.cpp.

◆ getParams() [2/2]

void ompl::base::ParamSet::getParams ( std::map< std::string, std::string > & params) const

Get the known parameter as a map from names to their values cast as string.

Definition at line 180 of file GenericParam.cpp.

◆ getParamValues()

void ompl::base::ParamSet::getParamValues ( std::vector< std::string > & vals) const

List the values of the known parameters, in the same order as getParamNames()

Definition at line 157 of file GenericParam.cpp.

◆ hasParam()

bool ompl::base::ParamSet::hasParam ( const std::string & key) const

Check whether this set of parameters includes the parameter named key.

Definition at line 186 of file GenericParam.cpp.

◆ include()

void ompl::base::ParamSet::include ( const ParamSet & other,
const std::string & prefix = "" )

Include the params of a different ParamSet into this one. Optionally include a prefix for each of the parameters.

Definition at line 198 of file GenericParam.cpp.

◆ operator[]()

ompl::base::GenericParam & ompl::base::ParamSet::operator[] ( const std::string & key)

Access operator for parameters, by name. If the parameter is not defined, an exception is thrown.

Definition at line 191 of file GenericParam.cpp.

◆ print()

void ompl::base::ParamSet::print ( std::ostream & out) const

Print the parameters to a stream.

Definition at line 224 of file GenericParam.cpp.

◆ remove()

void ompl::base::ParamSet::remove ( const std::string & name)

Remove a parameter from the set.

Definition at line 214 of file GenericParam.cpp.

◆ setParam()

bool ompl::base::ParamSet::setParam ( const std::string & key,
const std::string & value )

Algorithms in OMPL often have parameters that can be set externally. While each algorithm will have their own getter and setter functions specifically for those parameters, this function allows setting parameters generically, for any algorithm that declares parameters, by specifying the parameter name key and its value value (both as string, but value is cast to the type desired by the corresponding setter). Under the hood, this calls SpecificParam::setValue(). This ability makes it easy to automatically configure using external sources (e.g., a configuration file). The function returns true if the parameter was parsed and set successfully and false otherwise.

Definition at line 114 of file GenericParam.cpp.

◆ setParams()

bool ompl::base::ParamSet::setParams ( const std::map< std::string, std::string > & kv,
bool ignoreUnknown = false )

Set the values for a set of parameters. The parameter names are the keys in the map kv. The corresponding key values in kv are set as the parameter values. Return true if all parameters were set successfully. This function simply calls setParam() multiple times. If ignoreUnknown is true, then no attempt is made to set unknown parameters (and thus no errors are reported)

Definition at line 124 of file GenericParam.cpp.

◆ size()

std::size_t ompl::base::ParamSet::size ( ) const
inline

Get the number of parameters maintained by this instance.

Definition at line 298 of file GenericParam.h.


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