rclcpp  master
C++ ROS Client Library API
publisher_options.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__PUBLISHER_OPTIONS_HPP_
16 #define RCLCPP__PUBLISHER_OPTIONS_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
24 #include "rclcpp/qos.hpp"
25 #include "rclcpp/qos_event.hpp"
27 #include "rcl/publisher.h"
28 
29 namespace rclcpp
30 {
31 
34 {
37 
40 
42  rclcpp::callback_group::CallbackGroup::SharedPtr callback_group;
43 };
44 
46 template<typename Allocator>
48 {
50  std::shared_ptr<Allocator> allocator = nullptr;
51 
53 
55  explicit PublisherOptionsWithAllocator(const PublisherOptionsBase & publisher_options_base)
56  : PublisherOptionsBase(publisher_options_base)
57  {}
58 
60  template<typename MessageT>
63  {
65  using AllocatorTraits = std::allocator_traits<Allocator>;
66  using MessageAllocatorT = typename AllocatorTraits::template rebind_alloc<MessageT>;
67  auto message_alloc = std::make_shared<MessageAllocatorT>(*allocator.get());
68  result.allocator = allocator::get_rcl_allocator<MessageT>(*message_alloc);
69  result.qos = qos.get_rmw_qos_profile();
70  return result;
71  }
72 };
73 
75 
76 } // namespace rclcpp
77 
78 #endif // RCLCPP__PUBLISHER_OPTIONS_HPP_
PublisherOptionsWithAllocator(const PublisherOptionsBase &publisher_options_base)
Constructor using base class as input.
Definition: publisher_options.hpp:55
Non-templated part of PublisherOptionsWithAllocator<Allocator>.
Definition: publisher_options.hpp:33
Encapsulation of Quality of Service settings.
Definition: qos.hpp:55
Contains callbacks for various types of events a Publisher can receive from the middleware.
Definition: qos_event.hpp:42
PublisherEventCallbacks event_callbacks
Callbacks for various events related to publishers.
Definition: publisher_options.hpp:39
rmw_qos_profile_t qos
IntraProcessSetting
Used as argument in create_publisher and create_subscriber.
Definition: intra_process_setting.hpp:22
rmw_qos_profile_t & get_rmw_qos_profile()
Return the rmw qos profile.
This header provides the get_node_topics_interface() template function.
Definition: allocator_common.hpp:24
IntraProcessSetting use_intra_process_comm
Setting to explicitly set intraprocess communications.
Definition: publisher_options.hpp:36
rclcpp::callback_group::CallbackGroup::SharedPtr callback_group
Callback group in which the waitable items from the publisher should be placed.
Definition: publisher_options.hpp:42
rcl_allocator_t allocator
Structure containing optional configuration for Publishers.
Definition: publisher_options.hpp:47
T get(T... args)
rcl_publisher_options_t to_rcl_publisher_options(const rclcpp::QoS &qos) const
Convert this class, and a rclcpp::QoS, into an rcl_publisher_options_t.
Definition: publisher_options.hpp:62
Take intraprocess configuration from the node.