rclcpp  master
C++ ROS Client Library API
node_parameters_interface.hpp
Go to the documentation of this file.
1 // Copyright 2016 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_INTERFACE_HPP_
16 #define RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_INTERFACE_HPP_
17 
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "rcl_interfaces/msg/list_parameters_result.hpp"
24 #include "rcl_interfaces/msg/parameter_descriptor.hpp"
25 #include "rcl_interfaces/msg/set_parameters_result.hpp"
26 
27 #include "rclcpp/macros.hpp"
28 #include "rclcpp/parameter.hpp"
30 
31 namespace rclcpp
32 {
33 namespace node_interfaces
34 {
35 
37 {
39 
42  rcl_interfaces::msg::SetParametersResult(
44 
46 };
47 
50 {
51 public:
53 
55  virtual
56  ~NodeParametersInterface() = default;
57 
59 
63  virtual
66  const std::string & name,
67  const rclcpp::ParameterValue & default_value = rclcpp::ParameterValue(),
68  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor =
69  rcl_interfaces::msg::ParameterDescriptor(),
70  bool ignore_override = false) = 0;
71 
73 
77  virtual
78  void
79  undeclare_parameter(const std::string & name) = 0;
80 
82 
86  virtual
87  bool
88  has_parameter(const std::string & name) const = 0;
89 
91 
95  virtual
97  set_parameters(const std::vector<rclcpp::Parameter> & parameters) = 0;
98 
100 
104  virtual
105  rcl_interfaces::msg::SetParametersResult
107  const std::vector<rclcpp::Parameter> & parameters) = 0;
108 
110  /*
111  * \param[in] names a list of parameter names to check.
112  * \return the list of parameters that were found.
113  * Any parameter not found is omitted from the returned list.
114  */
116  virtual
118  get_parameters(const std::vector<std::string> & names) const = 0;
119 
121  /*
122  * \param[in] name the name of the parameter to look for.
123  * \return the parameter if it exists on the node.
124  * \throws std::out_of_range if the parameter does not exist on the node.
125  */
127  virtual
129  get_parameter(const std::string & name) const = 0;
130 
132  /*
133  * \param[in] name the name of the parameter to look for.
134  * \param[out] parameter the description if parameter exists on the node.
135  * \return true if the parameter exists on the node, or
136  * \return false if the parameter does not exist.
137  */
139  virtual
140  bool
142  const std::string & name,
143  rclcpp::Parameter & parameter) const = 0;
144 
146  /*
147  * \param[in] prefix the name of the prefix to look for.
148  * \param[out] parameters a map of parameters that matched the prefix.
149  * \return true if any parameters with the prefix exists on the node, or
150  * \return false otherwise.
151  */
153  virtual
154  bool
156  const std::string & prefix,
157  std::map<std::string, rclcpp::Parameter> & parameters) const = 0;
158 
160  virtual
162  describe_parameters(const std::vector<std::string> & names) const = 0;
163 
165  virtual
167  get_parameter_types(const std::vector<std::string> & names) const = 0;
168 
170  virtual
171  rcl_interfaces::msg::ListParametersResult
172  list_parameters(const std::vector<std::string> & prefixes, uint64_t depth) const = 0;
173 
175 
177 
181  virtual
182  OnSetParametersCallbackHandle::SharedPtr
184 
186 
190  virtual
191  void
193 
195 
199  [[deprecated("use add_on_set_parameters_callback(OnParametersSetCallbackType callback) instead")]]
201  virtual
204 
207  virtual
209  get_parameter_overrides() const = 0;
210 };
211 
212 } // namespace node_interfaces
213 } // namespace rclcpp
214 
215 #endif // RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_INTERFACE_HPP_
rclcpp::node_interfaces::NodeParametersInterface::get_parameters_by_prefix
virtual bool get_parameters_by_prefix(const std::string &prefix, std::map< std::string, rclcpp::Parameter > &parameters) const =0
Get all parameters that have the specified prefix into the parameters map.
rclcpp::node_interfaces::NodeParametersInterface::has_parameter
virtual bool has_parameter(const std::string &name) const =0
Return true if the parameter has been declared, otherwise false.
rclcpp::ParameterValue
Store the type and value of a parameter.
Definition: parameter_value.hpp:71
std::string
rclcpp::node_interfaces::NodeParametersInterface::describe_parameters
virtual std::vector< rcl_interfaces::msg::ParameterDescriptor > describe_parameters(const std::vector< std::string > &names) const =0
std::vector< rclcpp::Parameter >
RCLCPP_SMART_PTR_ALIASES_ONLY
#define RCLCPP_SMART_PTR_ALIASES_ONLY(...)
Definition: macros.hpp:66
rclcpp::node_interfaces::NodeParametersInterface::remove_on_set_parameters_callback
virtual void remove_on_set_parameters_callback(const OnSetParametersCallbackHandle *const handler)=0
Remove a callback registered with add_on_set_parameters_callback.
std::function< rcl_interfaces::msg::SetParametersResult(const std::vector< rclcpp::Parameter > &)>
rclcpp::node_interfaces::NodeParametersInterface::get_parameter
virtual rclcpp::Parameter get_parameter(const std::string &name) const =0
Get the description of one parameter given a name.
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
RCLCPP_PUBLIC
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
rclcpp::node_interfaces::OnSetParametersCallbackHandle
Definition: node_parameters_interface.hpp:36
rclcpp::node_interfaces::NodeParametersInterface::list_parameters
virtual rcl_interfaces::msg::ListParametersResult list_parameters(const std::vector< std::string > &prefixes, uint64_t depth) const =0
rclcpp::node_interfaces::NodeParametersInterface::get_parameter_types
virtual std::vector< uint8_t > get_parameter_types(const std::vector< std::string > &names) const =0
RCLCPP_SMART_PTR_DEFINITIONS
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
macros.hpp
rclcpp::node_interfaces::NodeParametersInterface
Pure virtual interface class for the NodeParameters part of the Node API.
Definition: node_parameters_interface.hpp:49
rclcpp::node_interfaces::OnSetParametersCallbackHandle::OnParametersSetCallbackType
std::function< rcl_interfaces::msg::SetParametersResult(const std::vector< rclcpp::Parameter > &)> OnParametersSetCallbackType
Definition: node_parameters_interface.hpp:43
rclcpp::node_interfaces::NodeParametersInterface::set_on_parameters_set_callback
virtual OnParametersSetCallbackType set_on_parameters_set_callback(OnParametersSetCallbackType callback)=0
Register a callback for when parameters are being set, return an existing one.
rclcpp::node_interfaces::NodeParametersInterface::get_parameter_overrides
virtual const std::map< std::string, rclcpp::ParameterValue > & get_parameter_overrides() const =0
Return the initial parameter values used by the NodeParameters to override default values.
rclcpp::node_interfaces::NodeParametersInterface::set_parameters_atomically
virtual rcl_interfaces::msg::SetParametersResult set_parameters_atomically(const std::vector< rclcpp::Parameter > &parameters)=0
Set and initialize a parameter, all at once.
rclcpp::node_interfaces::OnSetParametersCallbackHandle::callback
OnParametersSetCallbackType callback
Definition: node_parameters_interface.hpp:45
std::map
rclcpp::node_interfaces::NodeParametersInterface::set_parameters
virtual std::vector< rcl_interfaces::msg::SetParametersResult > set_parameters(const std::vector< rclcpp::Parameter > &parameters)=0
Set one or more parameters, one at a time.
parameter.hpp
rclcpp::node_interfaces::NodeParametersInterface::undeclare_parameter
virtual void undeclare_parameter(const std::string &name)=0
Undeclare a parameter.
rclcpp::node_interfaces::NodeParametersInterface::get_parameters
virtual std::vector< rclcpp::Parameter > get_parameters(const std::vector< std::string > &names) const =0
Get descriptions of parameters given their names.
visibility_control.hpp
rclcpp::Parameter
Structure to store an arbitrary parameter with templated get/set methods.
Definition: parameter.hpp:52
rclcpp::node_interfaces::NodeParametersInterface::declare_parameter
virtual const rclcpp::ParameterValue & declare_parameter(const std::string &name, const rclcpp::ParameterValue &default_value=rclcpp::ParameterValue(), const rcl_interfaces::msg::ParameterDescriptor &parameter_descriptor=rcl_interfaces::msg::ParameterDescriptor(), bool ignore_override=false)=0
Declare and initialize a parameter.
rclcpp::node_interfaces::NodeParametersInterface::add_on_set_parameters_callback
virtual OnSetParametersCallbackHandle::SharedPtr add_on_set_parameters_callback(OnParametersSetCallbackType callback)=0
Add a callback for when parameters are being set.
rclcpp::node_interfaces::NodeParametersInterface::~NodeParametersInterface
virtual ~NodeParametersInterface()=default