15 #ifndef RCLCPP__PARAMETER_HPP_ 16 #define RCLCPP__PARAMETER_HPP_ 23 #include "rcl_interfaces/msg/parameter.hpp" 24 #include "rcl_interfaces/msg/parameter_type.hpp" 25 #include "rcl_interfaces/msg/parameter_value.hpp" 55 explicit ParameterVariant(
const std::string & name,
const int64_t int_value);
57 explicit ParameterVariant(
const std::string & name,
const float double_value);
59 explicit ParameterVariant(
const std::string & name,
const double double_value);
61 explicit ParameterVariant(
const std::string & name,
const std::string & string_value);
63 explicit ParameterVariant(
const std::string & name,
const char * string_value);
65 explicit ParameterVariant(
const std::string & name,
const std::vector<uint8_t> & bytes_value);
80 rcl_interfaces::msg::ParameterValue
85 template<ParameterType type>
86 typename std::enable_if<type == ParameterType::PARAMETER_INTEGER, int64_t>::type
91 throw std::runtime_error(
"Invalid type");
93 return value_.integer_value;
96 template<ParameterType type>
97 typename std::enable_if<type == ParameterType::PARAMETER_DOUBLE, double>::type
102 throw std::runtime_error(
"Invalid type");
104 return value_.double_value;
107 template<ParameterType type>
108 typename std::enable_if<type == ParameterType::PARAMETER_STRING, const std::string &>::type
113 throw std::runtime_error(
"Invalid type");
115 return value_.string_value;
118 template<ParameterType type>
119 typename std::enable_if<type == ParameterType::PARAMETER_BOOL, bool>::type
124 throw std::runtime_error(
"Invalid type");
126 return value_.bool_value;
129 template<ParameterType type>
130 typename std::enable_if<
136 throw std::runtime_error(
"Invalid type");
138 return value_.bytes_value;
143 template<
typename type>
144 typename std::enable_if<
145 std::is_integral<type>::value && !std::is_same<type, bool>::value, int64_t>::type
148 return get_value<ParameterType::PARAMETER_INTEGER>();
151 template<
typename type>
152 typename std::enable_if<std::is_floating_point<type>::value,
double>::type
155 return get_value<ParameterType::PARAMETER_DOUBLE>();
158 template<
typename type>
159 typename std::enable_if<std::is_convertible<type, std::string>::value,
const std::string &>::type
162 return get_value<ParameterType::PARAMETER_STRING>();
165 template<
typename type>
166 typename std::enable_if<std::is_same<type, bool>::value,
bool>::type
169 return get_value<ParameterType::PARAMETER_BOOL>();
172 template<
typename type>
173 typename std::enable_if<
175 type,
const std::vector<uint8_t> &>::value,
const std::vector<uint8_t> &>::type
178 return get_value<ParameterType::PARAMETER_BYTES>();
198 const std::vector<uint8_t> &
202 static ParameterVariant
206 rcl_interfaces::msg::Parameter
215 rcl_interfaces::msg::ParameterValue value_;
230 operator<<(std::ostream & os, const std::vector<ParameterVariant> & parameters);
246 to_string(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters);
250 #endif // RCLCPP__PARAMETER_HPP_
rcl_interfaces::msg::ParameterValue get_parameter_value() const
std::ostream & operator<<(std::ostream &os, const rclcpp::parameter::ParameterVariant &pv)
std::enable_if< std::is_convertible< type, std::string >::value, const std::string & >::type get_value() const
Definition: parameter.hpp:160
Definition: parameter.hpp:40
Definition: allocator_common.hpp:24
Definition: parameter.hpp:235
std::enable_if< std::is_same< type, bool >::value, bool >::type get_value() const
Definition: parameter.hpp:167
Definition: parameter.hpp:37
static ParameterVariant from_parameter(const rcl_interfaces::msg::Parameter ¶meter)
std::string get_type_name() const
const std::string & as_string() const
std::string to_string(const std::vector< rclcpp::parameter::ParameterVariant > ¶meters)
Return a json encoded version of a vector of parameters, as a string.
std::enable_if< type==ParameterType::PARAMETER_BYTES, const std::vector< uint8_t > & >::type get_value() const
Definition: parameter.hpp:132
Definition: parameter.hpp:41
std::enable_if< type==ParameterType::PARAMETER_BOOL, bool >::type get_value() const
Definition: parameter.hpp:120
std::enable_if< type==ParameterType::PARAMETER_STRING, const std::string & >::type get_value() const
Definition: parameter.hpp:109
ParameterType
Definition: parameter.hpp:34
rcl_interfaces::msg::Parameter to_parameter()
std::enable_if< type==ParameterType::PARAMETER_INTEGER, int64_t >::type get_value() const
Definition: parameter.hpp:87
const std::vector< uint8_t > & as_bytes() const
std::enable_if< type==ParameterType::PARAMETER_DOUBLE, double >::type get_value() const
Definition: parameter.hpp:98
const std::string & get_name() const
std::enable_if< std::is_floating_point< type >::value, double >::type get_value() const
Definition: parameter.hpp:153
std::string _to_json_dict_entry(const ParameterVariant ¶m)
Return a json encoded version of the parameter intended for a dict.
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
std::enable_if< std::is_convertible< type, const std::vector< uint8_t > & >::value, const std::vector< uint8_t > & >::type get_value() const
Definition: parameter.hpp:176
ParameterType get_type() const
Definition: parameter.hpp:45
Definition: parameter.hpp:36
Definition: parameter.hpp:39
std::enable_if< std::is_integral< type >::value &&!std::is_same< type, bool >::value, int64_t >::type get_value() const
Definition: parameter.hpp:146
std::string value_to_string() const
Definition: parameter.hpp:38