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_
27 #include "rcl/error_handling.h"
35 #include "tracetools/tracetools.h"
39 namespace experimental
46 typename CallbackMessageT = MessageT>
65 std::shared_ptr<Alloc> allocator,
67 const
std::
string & topic_name,
71 any_callback_(callback)
78 buffer_ = rclcpp::experimental::create_intra_process_buffer<MessageT, Alloc, Deleter>(
89 &
gc_, context->get_rcl_context().get(), guard_condition_options);
92 throw std::runtime_error(
"SubscriptionIntraProcess init error initializing guard condition");
96 rclcpp_subscription_callback_added,
97 static_cast<const void *
>(
this),
98 static_cast<const void *
>(&any_callback_));
102 #ifndef TRACETOOLS_DISABLED
103 any_callback_.register_callback_for_tracing();
112 "Failed to destroy guard condition: %s",
121 return buffer_->has_data();
130 if (any_callback_.use_take_shared_method()) {
131 shared_msg = buffer_->consume_shared();
133 unique_msg = buffer_->consume_unique();
135 return std::static_pointer_cast<void>(
144 execute_impl<CallbackMessageT>(data);
151 trigger_guard_condition();
158 trigger_guard_condition();
164 return buffer_->use_take_shared_method();
169 trigger_guard_condition()
180 throw std::runtime_error(
"Subscription intra-process can't handle serialized messages");
195 auto shared_ptr = std::static_pointer_cast<std::pair<ConstMessageSharedPtr, MessageUniquePtr>>(
198 if (any_callback_.use_take_shared_method()) {
200 any_callback_.dispatch_intra_process(shared_msg, msg_info);
203 any_callback_.dispatch_intra_process(
std::move(unique_msg), msg_info);
208 AnySubscriptionCallback<CallbackMessageT, Alloc> any_callback_;
215 #endif // RCLCPP__EXPERIMENTAL__SUBSCRIPTION_INTRA_PROCESS_HPP_
void provide_intra_process_message(ConstMessageSharedPtr message)
Definition: subscription_intra_process.hpp:148
rcl_ret_t rcl_trigger_guard_condition(rcl_guard_condition_t *guard_condition)
void execute(std::shared_ptr< void > &data)
Execute data that is passed in.
Definition: subscription_intra_process.hpp:142
typename rclcpp::experimental::buffers::IntraProcessBuffer< MessageT, Alloc, Deleter >::UniquePtr BufferUniquePtr
Definition: subscription_intra_process.hpp:61
void provide_intra_process_message(MessageUniquePtr message)
Definition: subscription_intra_process.hpp:155
bool use_take_shared_method() const
Definition: subscription_intra_process.hpp:162
rcutils_error_string_t rcutils_get_error_string(void)
Definition: subscription_intra_process_base.hpp:36
allocator::AllocRebind< MessageT, Alloc > MessageAllocTraits
Definition: subscription_intra_process.hpp:52
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:55
~SubscriptionIntraProcess()
Definition: subscription_intra_process.hpp:107
#define RCUTILS_LOG_ERROR_NAMED(name,...)
typename MessageAllocTraits::allocator_type MessageAlloc
Definition: subscription_intra_process.hpp:53
rcl_guard_condition_options_t rcl_guard_condition_get_default_options(void)
typename std::allocator_traits< Alloc >::template rebind_traits< T > AllocRebind
Definition: allocator_common.hpp:30
rcl_ret_t rcl_guard_condition_init(rcl_guard_condition_t *guard_condition, rcl_context_t *context, const rcl_guard_condition_options_t options)
rcl_guard_condition_t rcl_get_zero_initialized_guard_condition(void)
Definition: subscription_intra_process.hpp:47
Definition: any_subscription_callback.hpp:101
Context which encapsulates shared state between nodes and other similar entities.
Definition: context.hpp:68
rcl_ret_t rcl_guard_condition_fini(rcl_guard_condition_t *guard_condition)
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
IntraProcessBufferType
Definition: intra_process_buffer_type.hpp:23
rcl_guard_condition_t gc_
Definition: subscription_intra_process_base.hpp:79
std::shared_ptr< void > take_data()
Take the data so that it can be consumed with execute.
Definition: subscription_intra_process.hpp:125
bool is_ready(rcl_wait_set_t *wait_set)
Check if the Waitable is ready.
Definition: subscription_intra_process.hpp:118
std::shared_ptr< const MessageT > ConstMessageSharedPtr
Definition: subscription_intra_process.hpp:54