15 #ifndef RCLCPP__ANY_SUBSCRIPTION_CALLBACK_HPP_    16 #define RCLCPP__ANY_SUBSCRIPTION_CALLBACK_HPP_    23 #include <type_traits>    33 namespace any_subscription_callback
    36 template<
typename MessageT, 
typename Alloc>
    40   using MessageAlloc = 
typename MessageAllocTraits::allocator_type;
    63   : shared_ptr_callback_(nullptr), shared_ptr_with_info_callback_(nullptr),
    64     const_shared_ptr_callback_(nullptr), const_shared_ptr_with_info_callback_(nullptr),
    65     unique_ptr_callback_(nullptr), unique_ptr_with_info_callback_(nullptr)
    67     message_allocator_ = std::make_shared<MessageAlloc>(*allocator.
get());
    82   void set(CallbackT callback)
    84     shared_ptr_callback_ = callback;
    96   void set(CallbackT callback)
    98     shared_ptr_with_info_callback_ = callback;
   110   void set(CallbackT callback)
   112     const_shared_ptr_callback_ = callback;
   124   void set(CallbackT callback)
   126     const_shared_ptr_with_info_callback_ = callback;
   138   void set(CallbackT callback)
   140     unique_ptr_callback_ = callback;
   152   void set(CallbackT callback)
   154     unique_ptr_with_info_callback_ = callback;
   161     if (shared_ptr_callback_) {
   162       shared_ptr_callback_(message);
   163     } 
else if (shared_ptr_with_info_callback_) {
   164       shared_ptr_with_info_callback_(message, message_info);
   165     } 
else if (const_shared_ptr_callback_) {
   166       const_shared_ptr_callback_(message);
   167     } 
else if (const_shared_ptr_with_info_callback_) {
   168       const_shared_ptr_with_info_callback_(message, message_info);
   169     } 
else if (unique_ptr_callback_) {
   170       auto ptr = MessageAllocTraits::allocate(*message_allocator_.
get(), 1);
   171       MessageAllocTraits::construct(*message_allocator_.
get(), ptr, *message);
   173     } 
else if (unique_ptr_with_info_callback_) {
   174       auto ptr = MessageAllocTraits::allocate(*message_allocator_.
get(), 1);
   175       MessageAllocTraits::construct(*message_allocator_.
get(), ptr, *message);
   176       unique_ptr_with_info_callback_(
MessageUniquePtr(ptr, message_deleter_), message_info);
   186     if (shared_ptr_callback_) {
   188       shared_ptr_callback_(shared_message);
   189     } 
else if (shared_ptr_with_info_callback_) {
   191       shared_ptr_with_info_callback_(shared_message, message_info);
   192     } 
else if (const_shared_ptr_callback_) {
   194       const_shared_ptr_callback_(const_shared_message);
   195     } 
else if (const_shared_ptr_with_info_callback_) {
   197       const_shared_ptr_with_info_callback_(const_shared_message, message_info);
   198     } 
else if (unique_ptr_callback_) {
   199       unique_ptr_callback_(
std::move(message));
   200     } 
else if (unique_ptr_with_info_callback_) {
   201       unique_ptr_with_info_callback_(
std::move(message), message_info);
   209   MessageDeleter message_deleter_;
   215 #endif  // RCLCPP__ANY_SUBSCRIPTION_CALLBACK_HPP_ 
Definition: any_subscription_callback.hpp:37
 
Definition: allocator_common.hpp:24
 
void set_allocator_for_deleter(D *deleter, Alloc *alloc)
Definition: allocator_deleter.hpp:72
 
typename std::allocator_traits< Alloc >::template rebind_traits< T > AllocRebind
Definition: allocator_common.hpp:30
 
AnySubscriptionCallback(std::shared_ptr< Alloc > allocator)
Definition: any_subscription_callback.hpp:62
 
Definition: function_traits.hpp:141
 
void dispatch_intra_process(MessageUniquePtr &message, const rmw_message_info_t &message_info)
Definition: any_subscription_callback.hpp:182
 
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 dispatch(std::shared_ptr< MessageT > message, const rmw_message_info_t &message_info)
Definition: any_subscription_callback.hpp:157