rclcpp_components  master
Package containing tools for dynamically loadable components
node_factory_template.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_FACTORY_TEMPLATE_HPP__
16 #define RCLCPP_COMPONENTS__NODE_FACTORY_TEMPLATE_HPP__
17 
18 #include <functional>
19 #include <memory>
20 
22 
23 namespace rclcpp_components
24 {
25 
27 
31 template<typename NodeT>
33 {
34 public:
35  NodeFactoryTemplate() = default;
36  virtual ~NodeFactoryTemplate() = default;
37 
39 
43  create_node_instance(const rclcpp::NodeOptions & options) override
44  {
45  auto node = std::make_shared<NodeT>(options);
46 
47  return NodeInstanceWrapper(
48  node, std::bind(&NodeT::get_node_base_interface, node));
49  }
50 };
51 } // namespace rclcpp_components
52 
53 #endif // RCLCPP_COMPONENTS__NODE_FACTORY_TEMPLATE_HPP__
std::bind
T bind(T... args)
node_factory.hpp
rclcpp_components::NodeInstanceWrapper
The NodeInstanceWrapper encapsulates the node instance.
Definition: node_instance_wrapper.hpp:26
rclcpp_components::NodeFactoryTemplate::NodeFactoryTemplate
NodeFactoryTemplate()=default
rclcpp_components::NodeFactory
The NodeFactory interface is used by the class loader to instantiate components.
Definition: node_factory.hpp:29
rclcpp::NodeOptions
rclcpp_components
Definition: component_manager.hpp:66
rclcpp_components::NodeFactoryTemplate::create_node_instance
NodeInstanceWrapper create_node_instance(const rclcpp::NodeOptions &options) override
Create an instance of a component.
Definition: node_factory_template.hpp:43
rclcpp_components::NodeFactoryTemplate::~NodeFactoryTemplate
virtual ~NodeFactoryTemplate()=default
rclcpp_components::NodeFactoryTemplate
NodeFactoryTemplate is a convenience class for instantiating components.
Definition: node_factory_template.hpp:32