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 <string>
20 #include <vector>
21 
22 #include "rcl_interfaces/msg/list_parameters_result.hpp"
23 #include "rcl_interfaces/msg/parameter_descriptor.hpp"
24 #include "rcl_interfaces/msg/set_parameters_result.hpp"
25 
26 #include "rclcpp/macros.hpp"
27 #include "rclcpp/parameter.hpp"
29 
30 namespace rclcpp
31 {
32 namespace node_interfaces
33 {
34 
37 {
38 public:
40 
42  virtual
43  ~NodeParametersInterface() = default;
44 
46 
50  virtual
53  const std::string & name,
54  const rclcpp::ParameterValue & default_value,
55  const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor) = 0;
56 
58 
62  virtual
63  void
64  undeclare_parameter(const std::string & name) = 0;
65 
67 
71  virtual
72  bool
73  has_parameter(const std::string & name) const = 0;
74 
76 
80  virtual
82  set_parameters(const std::vector<rclcpp::Parameter> & parameters) = 0;
83 
85 
89  virtual
90  rcl_interfaces::msg::SetParametersResult
92  const std::vector<rclcpp::Parameter> & parameters) = 0;
93 
95  /*
96  * \param[in] names a list of parameter names to check.
97  * \return the list of parameters that were found.
98  * Any parameter not found is omitted from the returned list.
99  */
101  virtual
103  get_parameters(const std::vector<std::string> & names) const = 0;
104 
106  /*
107  * \param[in] name the name of the parameter to look for.
108  * \return the parameter if it exists on the node.
109  * \throws std::out_of_range if the parameter does not exist on the node.
110  */
112  virtual
114  get_parameter(const std::string & name) const = 0;
115 
117  /*
118  * \param[in] name the name of the parameter to look for.
119  * \param[out] parameter the description if parameter exists on the node.
120  * \return true if the parameter exists on the node, or
121  * \return false if the parameter does not exist.
122  */
124  virtual
125  bool
127  const std::string & name,
128  rclcpp::Parameter & parameter) const = 0;
129 
131  /*
132  * \param[in] prefix the name of the prefix to look for.
133  * \param[out] parameters a map of parameters that matched the prefix.
134  * \return true if any parameters with the prefix exists on the node, or
135  * \return false otherwise.
136  */
138  virtual
139  bool
141  const std::string & prefix,
142  std::map<std::string, rclcpp::Parameter> & parameters) const = 0;
143 
145  virtual
147  describe_parameters(const std::vector<std::string> & names) const = 0;
148 
150  virtual
152  get_parameter_types(const std::vector<std::string> & names) const = 0;
153 
155  virtual
156  rcl_interfaces::msg::ListParametersResult
157  list_parameters(const std::vector<std::string> & prefixes, uint64_t depth) const = 0;
158 
161  rcl_interfaces::msg::SetParametersResult(const std::vector<rclcpp::Parameter> &)
162  >;
163 
164  using ParametersCallbackFunction [[deprecated("use OnParametersSetCallbackType instead")]] =
166 
168 
172  virtual
175 
176  [[deprecated("use set_on_parameters_set_callback() instead")]]
178  virtual
179  void
181 
184  virtual
186  get_parameter_overrides() const = 0;
187 };
188 
189 } // namespace node_interfaces
190 } // namespace rclcpp
191 
192 #endif // RCLCPP__NODE_INTERFACES__NODE_PARAMETERS_INTERFACE_HPP_
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.
virtual std::vector< rcl_interfaces::msg::ParameterDescriptor > describe_parameters(const std::vector< std::string > &names) const =0
virtual void register_param_change_callback(OnParametersSetCallbackType callback)=0
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
virtual OnParametersSetCallbackType set_on_parameters_set_callback(OnParametersSetCallbackType callback)=0
Register a callback for when parameters are being set, return an existing one.
virtual const rclcpp::ParameterValue & declare_parameter(const std::string &name, const rclcpp::ParameterValue &default_value, const rcl_interfaces::msg::ParameterDescriptor &parameter_descriptor)=0
Declare and initialize a parameter.
This header provides the get_node_topics_interface() template function.
Definition: allocator_common.hpp:24
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...
std::function< rcl_interfaces::msg::SetParametersResult(const std::vector< rclcpp::Parameter > &) > OnParametersSetCallbackType
Definition: node_parameters_interface.hpp:162
virtual rcl_interfaces::msg::ListParametersResult list_parameters(const std::vector< std::string > &prefixes, uint64_t depth) const =0
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.
virtual std::vector< rclcpp::Parameter > get_parameters(const std::vector< std::string > &names) const =0
Get descriptions of parameters given their names.
virtual bool has_parameter(const std::string &name) const =0
Return true if the parameter has been declared, otherwise false.
virtual void undeclare_parameter(const std::string &name)=0
Undeclare a parameter.
virtual rclcpp::Parameter get_parameter(const std::string &name) const =0
Get the description of one parameter given a name.
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
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:36
virtual std::vector< uint8_t > get_parameter_types(const std::vector< std::string > &names) const =0
virtual rcl_interfaces::msg::SetParametersResult set_parameters_atomically(const std::vector< rclcpp::Parameter > &parameters)=0
Set and initialize a parameter, all at once.