Skip to content

Commit

Permalink
Added support for bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteve Fernandez committed Apr 30, 2015
1 parent f23b9e8 commit 54acb9c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rclcpp/include/rclcpp/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ class ParameterVariant
value_.string_value = string_value;
value_.parameter_type = rcl_interfaces::ParameterType::PARAMETER_STRING;
}
ParameterVariant(const std::string & name, const std::vector<int8_t> & bytes_value)
: name_(name)
{
value_.bytes_value = bytes_value;
value_.parameter_type = rcl_interfaces::ParameterType::PARAMETER_BYTES;
}

/* Templated getter */
template<typename T>
Expand Down Expand Up @@ -136,6 +142,15 @@ inline bool ParameterVariant::get_value() const
}
return value_.bool_value;
}
template<>
inline std::vector<int8_t> ParameterVariant::get_value() const
{
if (value_.parameter_type != rcl_interfaces::ParameterType::PARAMETER_BYTES) {
// TODO: use custom exception
throw std::runtime_error("Invalid type");
}
return value_.bytes_value;
}

class AsyncParametersClient
{
Expand Down

0 comments on commit 54acb9c

Please sign in to comment.