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
65  declare_parameter(
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
106  set_parameters_atomically(
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
141  get_parameter(
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
155  get_parameters_by_prefix(
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
183  add_on_set_parameters_callback(OnParametersSetCallbackType callback) = 0;
184 
186 
190  virtual
191  void
192  remove_on_set_parameters_callback(const OnSetParametersCallbackHandle * const handler) = 0;
193 
195 
199  virtual
201  set_on_parameters_set_callback(OnParametersSetCallbackType callback) = 0;
202 
205  virtual
207  get_parameter_overrides() const = 0;
208 };
209 
210 } // namespace node_interfaces
211 } // namespace rclcpp
212 
213 #endif // RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_INTERFACE_HPP_
Structure to store an arbitrary parameter with templated get/set methods.
Definition: parameter.hpp:51
#define RCLCPP_SMART_PTR_ALIASES_ONLY(...)
Definition: macros.hpp:66
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
std::function< rcl_interfaces::msg::SetParametersResult(const std::vector< rclcpp::Parameter > &)> OnParametersSetCallbackType
Definition: node_parameters_interface.hpp:43
Definition: node_parameters_interface.hpp:36
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Set the data type used in the intra-process buffer as std::shared_ptr<MessageT>
OnParametersSetCallbackType callback
Definition: node_parameters_interface.hpp:45
Store the type and value of a parameter.
Definition: parameter_value.hpp:71
Pure virtual interface class for the NodeParameters part of the Node API.
Definition: node_parameters_interface.hpp:49