Skip to content

Commit

Permalink
rclcpp::parameter::ParameterVariant -> rclcpp::Parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sloretz committed May 29, 2018
1 parent a79730e commit 6c441ca
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 166 deletions.
10 changes: 5 additions & 5 deletions rclcpp/include/rclcpp/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ class Node : public std::enable_shared_from_this<Node>

RCLCPP_PUBLIC
std::vector<rcl_interfaces::msg::SetParametersResult>
set_parameters(const std::vector<rclcpp::parameter::ParameterVariant> & parameters);
set_parameters(const std::vector<rclcpp::Parameter> & parameters);

RCLCPP_PUBLIC
rcl_interfaces::msg::SetParametersResult
set_parameters_atomically(const std::vector<rclcpp::parameter::ParameterVariant> & parameters);
set_parameters_atomically(const std::vector<rclcpp::Parameter> & parameters);

template<typename ParameterT>
void
Expand All @@ -269,18 +269,18 @@ class Node : public std::enable_shared_from_this<Node>
const ParameterT & value);

RCLCPP_PUBLIC
std::vector<rclcpp::parameter::ParameterVariant>
std::vector<rclcpp::Parameter>
get_parameters(const std::vector<std::string> & names) const;

RCLCPP_PUBLIC
rclcpp::parameter::ParameterVariant
rclcpp::Parameter
get_parameter(const std::string & name) const;

RCLCPP_PUBLIC
bool
get_parameter(
const std::string & name,
rclcpp::parameter::ParameterVariant & parameter) const;
rclcpp::Parameter & parameter) const;

/// Assign the value of the parameter if set into the parameter argument.
/**
Expand Down
12 changes: 6 additions & 6 deletions rclcpp/include/rclcpp/node_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ Node::set_parameter_if_not_set(
const std::string & name,
const ParameterT & value)
{
rclcpp::parameter::ParameterVariant parameter_variant;
if (!this->get_parameter(name, parameter_variant)) {
rclcpp::Parameter parameter;
if (!this->get_parameter(name, parameter)) {
this->set_parameters({
rclcpp::parameter::ParameterVariant(name, value),
rclcpp::Parameter(name, value),
});
}
}
Expand All @@ -215,10 +215,10 @@ template<typename ParameterT>
bool
Node::get_parameter(const std::string & name, ParameterT & value) const
{
rclcpp::parameter::ParameterVariant parameter_variant;
bool result = get_parameter(name, parameter_variant);
rclcpp::Parameter parameter;
bool result = get_parameter(name, parameter);
if (result) {
value = parameter_variant.get_value<ParameterT>();
value = parameter.get_value<ParameterT>();
}

return result;
Expand Down
12 changes: 6 additions & 6 deletions rclcpp/include/rclcpp/node_interfaces/node_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,30 @@ class NodeParameters : public NodeParametersInterface
virtual
std::vector<rcl_interfaces::msg::SetParametersResult>
set_parameters(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters);
const std::vector<rclcpp::Parameter> & parameters);

RCLCPP_PUBLIC
virtual
rcl_interfaces::msg::SetParametersResult
set_parameters_atomically(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters);
const std::vector<rclcpp::Parameter> & parameters);

RCLCPP_PUBLIC
virtual
std::vector<rclcpp::parameter::ParameterVariant>
std::vector<rclcpp::Parameter>
get_parameters(const std::vector<std::string> & names) const;

RCLCPP_PUBLIC
virtual
rclcpp::parameter::ParameterVariant
rclcpp::Parameter
get_parameter(const std::string & name) const;

RCLCPP_PUBLIC
virtual
bool
get_parameter(
const std::string & name,
rclcpp::parameter::ParameterVariant & parameter) const;
rclcpp::Parameter & parameter) const;

RCLCPP_PUBLIC
virtual
Expand Down Expand Up @@ -114,7 +114,7 @@ class NodeParameters : public NodeParametersInterface

ParametersCallbackFunction parameters_callback_ = nullptr;

std::map<std::string, rclcpp::parameter::ParameterVariant> parameters_;
std::map<std::string, rclcpp::Parameter> parameters_;

Publisher<rcl_interfaces::msg::ParameterEvent>::SharedPtr events_publisher_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,30 @@ class NodeParametersInterface
virtual
std::vector<rcl_interfaces::msg::SetParametersResult>
set_parameters(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters) = 0;
const std::vector<rclcpp::Parameter> & parameters) = 0;

RCLCPP_PUBLIC
virtual
rcl_interfaces::msg::SetParametersResult
set_parameters_atomically(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters) = 0;
const std::vector<rclcpp::Parameter> & parameters) = 0;

RCLCPP_PUBLIC
virtual
std::vector<rclcpp::parameter::ParameterVariant>
std::vector<rclcpp::Parameter>
get_parameters(const std::vector<std::string> & names) const = 0;

RCLCPP_PUBLIC
virtual
rclcpp::parameter::ParameterVariant
rclcpp::Parameter
get_parameter(const std::string & name) const = 0;

RCLCPP_PUBLIC
virtual
bool
get_parameter(
const std::string & name,
rclcpp::parameter::ParameterVariant & parameter) const = 0;
rclcpp::Parameter & parameter) const = 0;

RCLCPP_PUBLIC
virtual
Expand All @@ -83,7 +83,7 @@ class NodeParametersInterface

using ParametersCallbackFunction = std::function<
rcl_interfaces::msg::SetParametersResult(
const std::vector<rclcpp::parameter::ParameterVariant> &)>;
const std::vector<rclcpp::Parameter> &)>;

RCLCPP_PUBLIC
virtual
Expand Down
25 changes: 11 additions & 14 deletions rclcpp/include/rclcpp/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,21 @@

namespace rclcpp
{
namespace parameter
{

// Structure to store an arbitrary parameter with templated get/set methods
class ParameterVariant
class Parameter
{
public:
RCLCPP_PUBLIC
ParameterVariant();
Parameter();

RCLCPP_PUBLIC
ParameterVariant(const std::string & name, const ParameterValue & value);
Parameter(const std::string & name, const ParameterValue & value);

template<typename ValueTypeT>
RCLCPP_PUBLIC
explicit ParameterVariant(const std::string & name, ValueTypeT value)
: ParameterVariant(name, ParameterValue(value))
explicit Parameter(const std::string & name, ValueTypeT value)
: Parameter(name, ParameterValue(value))
{
}

Expand Down Expand Up @@ -116,7 +114,7 @@ class ParameterVariant
as_string_array() const;

RCLCPP_PUBLIC
static ParameterVariant
static Parameter
from_parameter(const rcl_interfaces::msg::Parameter & parameter);

RCLCPP_PUBLIC
Expand Down Expand Up @@ -158,17 +156,16 @@ class ParameterVariant
/// Return a json encoded version of the parameter intended for a dict.
RCLCPP_PUBLIC
std::string
_to_json_dict_entry(const ParameterVariant & param);
_to_json_dict_entry(const Parameter & param);

RCLCPP_PUBLIC
std::ostream &
operator<<(std::ostream & os, const rclcpp::parameter::ParameterVariant & pv);
operator<<(std::ostream & os, const rclcpp::Parameter & pv);

RCLCPP_PUBLIC
std::ostream &
operator<<(std::ostream & os, const std::vector<ParameterVariant> & parameters);
operator<<(std::ostream & os, const std::vector<Parameter> & parameters);

} // namespace parameter
} // namespace rclcpp

namespace std
Expand All @@ -177,12 +174,12 @@ namespace std
/// Return a json encoded version of the parameter intended for a list.
RCLCPP_PUBLIC
std::string
to_string(const rclcpp::parameter::ParameterVariant & param);
to_string(const rclcpp::Parameter & param);

/// Return a json encoded version of a vector of parameters, as a string.
RCLCPP_PUBLIC
std::string
to_string(const std::vector<rclcpp::parameter::ParameterVariant> & parameters);
to_string(const std::vector<rclcpp::Parameter> & parameters);

} // namespace std

Expand Down
14 changes: 7 additions & 7 deletions rclcpp/include/rclcpp/parameter_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class AsyncParametersClient
const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters);

RCLCPP_PUBLIC
std::shared_future<std::vector<rclcpp::parameter::ParameterVariant>>
std::shared_future<std::vector<rclcpp::Parameter>>
get_parameters(
const std::vector<std::string> & names,
std::function<
void(std::shared_future<std::vector<rclcpp::parameter::ParameterVariant>>)
void(std::shared_future<std::vector<rclcpp::Parameter>>)
> callback = nullptr);

RCLCPP_PUBLIC
Expand All @@ -86,15 +86,15 @@ class AsyncParametersClient
RCLCPP_PUBLIC
std::shared_future<std::vector<rcl_interfaces::msg::SetParametersResult>>
set_parameters(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters,
const std::vector<rclcpp::Parameter> & parameters,
std::function<
void(std::shared_future<std::vector<rcl_interfaces::msg::SetParametersResult>>)
> callback = nullptr);

RCLCPP_PUBLIC
std::shared_future<rcl_interfaces::msg::SetParametersResult>
set_parameters_atomically(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters,
const std::vector<rclcpp::Parameter> & parameters,
std::function<
void(std::shared_future<rcl_interfaces::msg::SetParametersResult>)
> callback = nullptr);
Expand Down Expand Up @@ -185,7 +185,7 @@ class SyncParametersClient
const rmw_qos_profile_t & qos_profile = rmw_qos_profile_parameters);

RCLCPP_PUBLIC
std::vector<rclcpp::parameter::ParameterVariant>
std::vector<rclcpp::Parameter>
get_parameters(const std::vector<std::string> & parameter_names);

RCLCPP_PUBLIC
Expand Down Expand Up @@ -231,11 +231,11 @@ class SyncParametersClient

RCLCPP_PUBLIC
std::vector<rcl_interfaces::msg::SetParametersResult>
set_parameters(const std::vector<rclcpp::parameter::ParameterVariant> & parameters);
set_parameters(const std::vector<rclcpp::Parameter> & parameters);

RCLCPP_PUBLIC
rcl_interfaces::msg::SetParametersResult
set_parameters_atomically(const std::vector<rclcpp::parameter::ParameterVariant> & parameters);
set_parameters_atomically(const std::vector<rclcpp::Parameter> & parameters);

RCLCPP_PUBLIC
rcl_interfaces::msg::ListParametersResult
Expand Down
2 changes: 1 addition & 1 deletion rclcpp/include/rclcpp/rclcpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* - rclcpp::Node::describe_parameters()
* - rclcpp::Node::list_parameters()
* - rclcpp::Node::register_param_change_callback()
* - rclcpp::parameter::ParameterVariant
* - rclcpp::Parameter
* - rclcpp::AsyncParametersClient
* - rclcpp::SyncParametersClient
* - rclcpp/parameter.hpp
Expand Down
10 changes: 5 additions & 5 deletions rclcpp/src/rclcpp/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,34 +117,34 @@ Node::group_in_node(rclcpp::callback_group::CallbackGroup::SharedPtr group)

std::vector<rcl_interfaces::msg::SetParametersResult>
Node::set_parameters(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters)
const std::vector<rclcpp::Parameter> & parameters)
{
return node_parameters_->set_parameters(parameters);
}

rcl_interfaces::msg::SetParametersResult
Node::set_parameters_atomically(
const std::vector<rclcpp::parameter::ParameterVariant> & parameters)
const std::vector<rclcpp::Parameter> & parameters)
{
return node_parameters_->set_parameters_atomically(parameters);
}

std::vector<rclcpp::parameter::ParameterVariant>
std::vector<rclcpp::Parameter>
Node::get_parameters(
const std::vector<std::string> & names) const
{
return node_parameters_->get_parameters(names);
}

rclcpp::parameter::ParameterVariant
rclcpp::Parameter
Node::get_parameter(const std::string & name) const
{
return node_parameters_->get_parameter(name);
}

bool Node::get_parameter(
const std::string & name,
rclcpp::parameter::ParameterVariant & parameter) const
rclcpp::Parameter & parameter) const
{
return node_parameters_->get_parameter(name, parameter);
}
Expand Down
Loading

0 comments on commit 6c441ca

Please sign in to comment.