rclcpp_components  master
Package containing tools for dynamically loadable components
node_instance_wrapper.hpp
Go to the documentation of this file.
1 // Copyright 2019 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_COMPONENTS__NODE_INSTANCE_WRAPPER_HPP__
16 #define RCLCPP_COMPONENTS__NODE_INSTANCE_WRAPPER_HPP__
17 
18 #include <functional>
19 #include <memory>
20 
22 
23 namespace rclcpp_components
24 {
27 {
28 public:
30  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr(const std::shared_ptr<void> &)>;
31 
33  : node_instance_(nullptr)
34  {}
35 
37  std::shared_ptr<void> node_instance,
38  NodeBaseInterfaceGetter node_base_interface_getter)
39  : node_instance_(node_instance), node_base_interface_getter_(node_base_interface_getter)
40  {}
41 
43 
51  {
52  return node_instance_;
53  }
54 
56 
59  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
61  {
62  return node_base_interface_getter_(node_instance_);
63  }
64 
65 private:
66  std::shared_ptr<void> node_instance_;
67  NodeBaseInterfaceGetter node_base_interface_getter_;
68 };
69 } // namespace rclcpp_components
70 
71 #endif // RCLCPP_COMPONENTS__NODE_INSTANCE_WRAPPER_HPP__
rclcpp_components::NodeInstanceWrapper::get_node_base_interface
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface()
Get NodeBaseInterface pointer for the encapsulated Node Instance.
Definition: node_instance_wrapper.hpp:60
std::shared_ptr< void >
rclcpp_components::NodeInstanceWrapper::NodeBaseInterfaceGetter
std::function< rclcpp::node_interfaces::NodeBaseInterface::SharedPtr(const std::shared_ptr< void > &)> NodeBaseInterfaceGetter
Definition: node_instance_wrapper.hpp:30
rclcpp_components::NodeInstanceWrapper
The NodeInstanceWrapper encapsulates the node instance.
Definition: node_instance_wrapper.hpp:26
node_base_interface.hpp
std::function< rclcpp::node_interfaces::NodeBaseInterface::SharedPtr(const std::shared_ptr< void > &)>
rclcpp_components::NodeInstanceWrapper::get_node_instance
const std::shared_ptr< void > get_node_instance() const
Get a type-erased pointer to the original Node instance.
Definition: node_instance_wrapper.hpp:50
rclcpp_components::NodeInstanceWrapper::NodeInstanceWrapper
NodeInstanceWrapper()
Definition: node_instance_wrapper.hpp:32
rclcpp_components::NodeInstanceWrapper::NodeInstanceWrapper
NodeInstanceWrapper(std::shared_ptr< void > node_instance, NodeBaseInterfaceGetter node_base_interface_getter)
Definition: node_instance_wrapper.hpp:36
rclcpp_components
Definition: component_manager.hpp:66