rclcpp  master
C++ ROS Client Library API
Public Member Functions | Static Public Member Functions | List of all members
rclcpp::Parameter Class Reference

Structure to store an arbitrary parameter with templated get/set methods. More...

#include <parameter.hpp>

Public Member Functions

 Parameter ()
 Construct with an empty name and a parameter value of type rclcpp::PARAMETER_NOT_SET. More...
 
 Parameter (const std::string &name)
 Construct with given name and a parameter value of type rclcpp::PARAMETER_NOT_SET. More...
 
 Parameter (const std::string &name, const ParameterValue &value)
 Construct with given name and given parameter value. More...
 
template<typename ValueTypeT >
 Parameter (const std::string &name, ValueTypeT value)
 Construct with given name and given parameter value. More...
 
 Parameter (const rclcpp::node_interfaces::ParameterInfo &parameter_info)
 
bool operator== (const Parameter &rhs) const
 Equal operator. More...
 
bool operator!= (const Parameter &rhs) const
 Not equal operator. More...
 
ParameterType get_type () const
 Get the type of the parameter. More...
 
std::string get_type_name () const
 Get the type name of the parameter. More...
 
const std::stringget_name () const
 Get the name of the parameter. More...
 
rcl_interfaces::msg::ParameterValue get_value_message () const
 Get value of parameter as a parameter message. More...
 
const rclcpp::ParameterValueget_parameter_value () const
 Get the internal storage for the parameter value. More...
 
template<ParameterType ParamT>
decltype(auto) get_value () const
 Get value of parameter using rclcpp::ParameterType as template argument. More...
 
template<typename T >
decltype(auto) get_value () const
 Get value of parameter using c++ types as template argument. More...
 
bool as_bool () const
 Get value of parameter as boolean. More...
 
int64_t as_int () const
 Get value of parameter as integer. More...
 
double as_double () const
 Get value of parameter as double. More...
 
const std::stringas_string () const
 Get value of parameter as string. More...
 
const std::vector< uint8_t > & as_byte_array () const
 Get value of parameter as byte array (vector<uint8_t>). More...
 
const std::vector< bool > & as_bool_array () const
 Get value of parameter as bool array (vector<bool>). More...
 
const std::vector< int64_t > & as_integer_array () const
 Get value of parameter as integer array (vector<int64_t>). More...
 
const std::vector< double > & as_double_array () const
 Get value of parameter as double array (vector<double>). More...
 
const std::vector< std::string > & as_string_array () const
 Get value of parameter as string array (vector<std::string>). More...
 
rcl_interfaces::msg::Parameter to_parameter_msg () const
 Convert the class in a parameter message. More...
 
std::string value_to_string () const
 Get value of parameter as a string. More...
 

Static Public Member Functions

static Parameter from_parameter_msg (const rcl_interfaces::msg::Parameter &parameter)
 Convert a parameter message in a Parameter class object. More...
 

Detailed Description

Structure to store an arbitrary parameter with templated get/set methods.

Constructor & Destructor Documentation

◆ Parameter() [1/5]

rclcpp::Parameter::Parameter ( )

Construct with an empty name and a parameter value of type rclcpp::PARAMETER_NOT_SET.

◆ Parameter() [2/5]

rclcpp::Parameter::Parameter ( const std::string name)
explicit

Construct with given name and a parameter value of type rclcpp::PARAMETER_NOT_SET.

◆ Parameter() [3/5]

rclcpp::Parameter::Parameter ( const std::string name,
const ParameterValue value 
)

Construct with given name and given parameter value.

◆ Parameter() [4/5]

template<typename ValueTypeT >
rclcpp::Parameter::Parameter ( const std::string name,
ValueTypeT  value 
)
inline

Construct with given name and given parameter value.

◆ Parameter() [5/5]

rclcpp::Parameter::Parameter ( const rclcpp::node_interfaces::ParameterInfo parameter_info)
explicit

Member Function Documentation

◆ operator==()

bool rclcpp::Parameter::operator== ( const Parameter rhs) const

Equal operator.

◆ operator!=()

bool rclcpp::Parameter::operator!= ( const Parameter rhs) const

Not equal operator.

◆ get_type()

ParameterType rclcpp::Parameter::get_type ( ) const

Get the type of the parameter.

◆ get_type_name()

std::string rclcpp::Parameter::get_type_name ( ) const

Get the type name of the parameter.

◆ get_name()

const std::string& rclcpp::Parameter::get_name ( ) const

Get the name of the parameter.

◆ get_value_message()

rcl_interfaces::msg::ParameterValue rclcpp::Parameter::get_value_message ( ) const

Get value of parameter as a parameter message.

◆ get_parameter_value()

const rclcpp::ParameterValue& rclcpp::Parameter::get_parameter_value ( ) const

Get the internal storage for the parameter value.

◆ get_value() [1/2]

template<ParameterType ParamT>
decltype(auto) rclcpp::Parameter::get_value ( ) const
inline

Get value of parameter using rclcpp::ParameterType as template argument.

Exceptions
rclcpp::exceptions::InvalidParameterTypeExceptionif the type doesn't match

◆ get_value() [2/2]

template<typename T >
decltype(auto) rclcpp::Parameter::get_value ( ) const

Get value of parameter using c++ types as template argument.

◆ as_bool()

bool rclcpp::Parameter::as_bool ( ) const

Get value of parameter as boolean.

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ as_int()

int64_t rclcpp::Parameter::as_int ( ) const

Get value of parameter as integer.

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ as_double()

double rclcpp::Parameter::as_double ( ) const

Get value of parameter as double.

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ as_string()

const std::string& rclcpp::Parameter::as_string ( ) const

Get value of parameter as string.

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ as_byte_array()

const std::vector<uint8_t>& rclcpp::Parameter::as_byte_array ( ) const

Get value of parameter as byte array (vector<uint8_t>).

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ as_bool_array()

const std::vector<bool>& rclcpp::Parameter::as_bool_array ( ) const

Get value of parameter as bool array (vector<bool>).

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ as_integer_array()

const std::vector<int64_t>& rclcpp::Parameter::as_integer_array ( ) const

Get value of parameter as integer array (vector<int64_t>).

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ as_double_array()

const std::vector<double>& rclcpp::Parameter::as_double_array ( ) const

Get value of parameter as double array (vector<double>).

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ as_string_array()

const std::vector<std::string>& rclcpp::Parameter::as_string_array ( ) const

Get value of parameter as string array (vector<std::string>).

Exceptions
rclcpp::ParameterTypeExceptionif the type doesn't match

◆ from_parameter_msg()

static Parameter rclcpp::Parameter::from_parameter_msg ( const rcl_interfaces::msg::Parameter &  parameter)
static

Convert a parameter message in a Parameter class object.

◆ to_parameter_msg()

rcl_interfaces::msg::Parameter rclcpp::Parameter::to_parameter_msg ( ) const

Convert the class in a parameter message.

◆ value_to_string()

std::string rclcpp::Parameter::value_to_string ( ) const

Get value of parameter as a string.


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