15 #ifndef RCLCPP__PUBLISHER_FACTORY_HPP_ 16 #define RCLCPP__PUBLISHER_FACTORY_HPP_ 24 #include "rosidl_typesupport_cpp/message_type_support.hpp" 49 rclcpp::publisher::PublisherBase::SharedPtr(
61 rclcpp::publisher::PublisherBase::SharedPtr publisher)>;
70 rclcpp::intra_process_manager::IntraProcessManager::SharedPtr ipm)>;
76 template<
typename MessageT,
typename Alloc,
typename PublisherT>
89 auto message_alloc = std::make_shared<typename PublisherT::MessageAlloc>(*allocator.
get());
90 publisher_options.allocator = allocator::get_rcl_allocator<MessageT>(*message_alloc.get());
92 return std::make_shared<PublisherT>(node_base, topic_name, publisher_options, message_alloc);
99 rclcpp::publisher::PublisherBase::SharedPtr publisher) -> uint64_t
107 [](rclcpp::intra_process_manager::IntraProcessManager::SharedPtr ipm) -> StoreMessageCallbackT
109 rclcpp::intra_process_manager::IntraProcessManager::WeakPtr weak_ipm = ipm;
113 auto shared_publish_callback =
114 [weak_ipm](uint64_t publisher_id,
void * msg,
const std::type_info & type_info) -> uint64_t
116 auto ipm = weak_ipm.lock();
120 "intra process publish called after destruction of intra process manager");
125 auto & message_type_info =
typeid(MessageT);
126 if (message_type_info != type_info) {
128 std::string(
"published type '") + type_info.name() +
129 "' is incompatible from the publisher type '" + message_type_info.name() +
"'");
131 MessageT * typed_message_ptr =
static_cast<MessageT *
>(msg);
134 uint64_t message_seq =
139 return shared_publish_callback;
148 #endif // RCLCPP__PUBLISHER_FACTORY_HPP_
This class facilitates intra process communication between nodes.
Definition: intra_process_manager.hpp:121
PublisherFactory create_publisher_factory(std::shared_ptr< Alloc > allocator)
Return a PublisherFactory with functions setup for creating a PublisherT<MessageT, Alloc>.
Definition: publisher_factory.hpp:78
Factory with functions used to create a MessageT specific PublisherT.
Definition: publisher_factory.hpp:45
Definition: allocator_common.hpp:24
uint64_t store_intra_process_message(uint64_t intra_process_publisher_id, std::unique_ptr< MessageT, Deleter > &message)
Store a message in the manager, and return the message sequence number.
Definition: intra_process_manager.hpp:244
uint64_t add_publisher(typename publisher::Publisher< MessageT, Alloc >::SharedPtr publisher, size_t buffer_size=0)
Register a publisher with the manager, returns the publisher unique id.
Definition: intra_process_manager.hpp:188
AddPublisherToIntraProcessManagerFunction add_publisher_to_intra_process_manager
Definition: publisher_factory.hpp:63
T dynamic_pointer_cast(T... args)
allocator::Deleter< MessageAlloc, MessageT > MessageDeleter
Definition: publisher.hpp:151
SharedPublishCallbackFactoryFunction create_shared_publish_callback
Definition: publisher_factory.hpp:72
Pure virtual interface class for the NodeBase part of the Node API.
Definition: node_base_interface.hpp:36
std::function< uint64_t(uint64_t, void *, const std::type_info &)> StoreMessageCallbackT
Definition: publisher.hpp:121
PublisherFactoryFunction create_typed_publisher
Definition: publisher_factory.hpp:54