rclcpp
master
C++ ROS Client Library API
|
Go to the documentation of this file.
15 #ifndef RCLCPP__EXPERIMENTAL__SUBSCRIPTION_INTRA_PROCESS_HPP_
16 #define RCLCPP__EXPERIMENTAL__SUBSCRIPTION_INTRA_PROCESS_HPP_
25 #include "rcl/error_handling.h"
33 #include "tracetools/tracetools.h"
37 namespace experimental
44 typename CallbackMessageT = MessageT>
63 std::shared_ptr<Alloc> allocator,
65 const
std::
string & topic_name,
69 any_callback_(callback)
76 buffer_ = rclcpp::experimental::create_intra_process_buffer<MessageT, Alloc, Deleter>(
83 rcl_guard_condition_get_default_options();
85 gc_ = rcl_get_zero_initialized_guard_condition();
86 rcl_ret_t ret = rcl_guard_condition_init(
87 &
gc_, context->get_rcl_context().get(), guard_condition_options);
89 if (RCL_RET_OK != ret) {
90 throw std::runtime_error(
"SubscriptionIntraProcess init error initializing guard condition");
94 rclcpp_subscription_callback_added,
96 (
const void *)&any_callback_);
100 #ifndef TRACETOOLS_DISABLED
101 any_callback_.register_callback_for_tracing();
109 return buffer_->has_data();
114 execute_impl<CallbackMessageT>();
121 trigger_guard_condition();
128 trigger_guard_condition();
134 return buffer_->use_take_shared_method();
139 trigger_guard_condition()
141 rcl_ret_t ret = rcl_trigger_guard_condition(&
gc_);
149 throw std::runtime_error(
"Subscription intra-process can't handle serialized messages");
160 if (any_callback_.use_take_shared_method()) {
162 any_callback_.dispatch_intra_process(msg, msg_info);
165 any_callback_.dispatch_intra_process(
std::move(msg), msg_info);
169 AnySubscriptionCallback<CallbackMessageT, Alloc> any_callback_;
176 #endif // RCLCPP__EXPERIMENTAL__SUBSCRIPTION_INTRA_PROCESS_HPP_
void provide_intra_process_message(ConstMessageSharedPtr message)
Definition: subscription_intra_process.hpp:118
typename rclcpp::experimental::buffers::IntraProcessBuffer< MessageT, Alloc, Deleter >::UniquePtr BufferUniquePtr
Definition: subscription_intra_process.hpp:59
void provide_intra_process_message(MessageUniquePtr message)
Definition: subscription_intra_process.hpp:125
bool use_take_shared_method() const
Definition: subscription_intra_process.hpp:132
Definition: subscription_intra_process_base.hpp:36
allocator::AllocRebind< MessageT, Alloc > MessageAllocTraits
Definition: subscription_intra_process.hpp:50
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
std::unique_ptr< MessageT, Deleter > MessageUniquePtr
Definition: subscription_intra_process.hpp:53
typename MessageAllocTraits::allocator_type MessageAlloc
Definition: subscription_intra_process.hpp:51
typename std::allocator_traits< Alloc >::template rebind_traits< T > AllocRebind
Definition: allocator_common.hpp:30
Definition: subscription_intra_process.hpp:45
Definition: any_subscription_callback.hpp:37
Context which encapsulates shared state between nodes and other similar entities.
Definition: context.hpp:56
typename std::conditional< std::is_same< typename std::allocator_traits< Alloc >::template rebind_alloc< T >, typename std::allocator< void >::template rebind< T >::other >::value, std::default_delete< T >, AllocatorDeleter< Alloc > >::type Deleter
Definition: allocator_deleter.hpp:101
void execute()
Execute any entities of the Waitable that are ready.
Definition: subscription_intra_process.hpp:112
IntraProcessBufferType
Definition: intra_process_buffer_type.hpp:23
rcl_guard_condition_t gc_
Definition: subscription_intra_process_base.hpp:75
bool is_ready(rcl_wait_set_t *wait_set)
Check if the Waitable is ready.
Definition: subscription_intra_process.hpp:106
std::shared_ptr< const MessageT > ConstMessageSharedPtr
Definition: subscription_intra_process.hpp:52