rclcpp  master
C++ ROS Client Library API
Public Types | Public Member Functions | List of all members
rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT > Class Template Reference

#include <subscription_intra_process.hpp>

Inheritance diagram for rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >:
Collaboration graph
[legend]

Public Types

using MessageAllocTraits = allocator::AllocRebind< MessageT, Alloc >
 
using MessageAlloc = typename MessageAllocTraits::allocator_type
 
using ConstMessageSharedPtr = std::shared_ptr< const MessageT >
 
using MessageUniquePtr = std::unique_ptr< MessageT, Deleter >
 
using BufferUniquePtr = typename rclcpp::experimental::buffers::IntraProcessBuffer< MessageT, Alloc, Deleter >::UniquePtr
 

Public Member Functions

 SubscriptionIntraProcess (AnySubscriptionCallback< CallbackMessageT, Alloc > callback, std::shared_ptr< Alloc > allocator, rclcpp::Context::SharedPtr context, const std::string &topic_name, rmw_qos_profile_t qos_profile, rclcpp::IntraProcessBufferType buffer_type)
 
 ~SubscriptionIntraProcess ()
 
bool is_ready (rcl_wait_set_t *wait_set)
 Check if the Waitable is ready. More...
 
std::shared_ptr< void > take_data ()
 Take the data so that it can be consumed with execute. More...
 
void execute (std::shared_ptr< void > &data)
 Execute data that is passed in. More...
 
void provide_intra_process_message (ConstMessageSharedPtr message)
 
void provide_intra_process_message (MessageUniquePtr message)
 
bool use_take_shared_method () const
 
- Public Member Functions inherited from rclcpp::experimental::SubscriptionIntraProcessBase
 SubscriptionIntraProcessBase (const std::string &topic_name, rmw_qos_profile_t qos_profile)
 
virtual ~SubscriptionIntraProcessBase ()=default
 
size_t get_number_of_ready_guard_conditions ()
 Get the number of ready guard_conditions. More...
 
bool add_to_wait_set (rcl_wait_set_t *wait_set)
 Add the Waitable to a wait set. More...
 
const char * get_topic_name () const
 
rmw_qos_profile_t get_actual_qos () const
 
- Public Member Functions inherited from rclcpp::Waitable
virtual ~Waitable ()=default
 
virtual size_t get_number_of_ready_subscriptions ()
 Get the number of ready subscriptions. More...
 
virtual size_t get_number_of_ready_timers ()
 Get the number of ready timers. More...
 
virtual size_t get_number_of_ready_clients ()
 Get the number of ready clients. More...
 
virtual size_t get_number_of_ready_events ()
 Get the number of ready events. More...
 
virtual size_t get_number_of_ready_services ()
 Get the number of ready services. More...
 
bool exchange_in_use_by_wait_set_state (bool in_use_state)
 Exchange the "in use by wait set" state for this timer. More...
 

Additional Inherited Members

- Protected Attributes inherited from rclcpp::experimental::SubscriptionIntraProcessBase
std::recursive_mutex reentrant_mutex_
 
rcl_guard_condition_t gc_
 

Member Typedef Documentation

◆ MessageAllocTraits

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
using rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::MessageAllocTraits = allocator::AllocRebind<MessageT, Alloc>

◆ MessageAlloc

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
using rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::MessageAlloc = typename MessageAllocTraits::allocator_type

◆ ConstMessageSharedPtr

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
using rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::ConstMessageSharedPtr = std::shared_ptr<const MessageT>

◆ MessageUniquePtr

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
using rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::MessageUniquePtr = std::unique_ptr<MessageT, Deleter>

◆ BufferUniquePtr

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
using rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::BufferUniquePtr = typename rclcpp::experimental::buffers::IntraProcessBuffer< MessageT, Alloc, Deleter >::UniquePtr

Constructor & Destructor Documentation

◆ SubscriptionIntraProcess()

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::SubscriptionIntraProcess ( AnySubscriptionCallback< CallbackMessageT, Alloc >  callback,
std::shared_ptr< Alloc >  allocator,
rclcpp::Context::SharedPtr  context,
const std::string topic_name,
rmw_qos_profile_t  qos_profile,
rclcpp::IntraProcessBufferType  buffer_type 
)
inline

◆ ~SubscriptionIntraProcess()

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::~SubscriptionIntraProcess ( )
inline

Member Function Documentation

◆ is_ready()

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
bool rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::is_ready ( rcl_wait_set_t wait_set)
inlinevirtual

Check if the Waitable is ready.

The input wait set should be the same that was used in a previously call to add_to_wait_set(). The wait set should also have been previously waited on with rcl_wait().

Parameters
[in]wait_setA handle to the wait set the Waitable was previously added to and that has been waited on.
Returns
true if the Waitable is ready, false otherwise.

Implements rclcpp::experimental::SubscriptionIntraProcessBase.

◆ take_data()

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
std::shared_ptr<void> rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::take_data ( )
inlinevirtual

Take the data so that it can be consumed with execute.

NOTE: take_data is a partial fix to a larger design issue with the multithreaded executor. This method is likely to be removed when a more permanent fix is implemented. A longterm fix is currently being discussed here: https://github.com/ros2/rclcpp/pull/1276

This method takes the data from the underlying data structure and writes it to the void shared pointer data that is passed into the method. The data can then be executed with the execute method.

Before calling this method, the Waitable should be added to a wait set, waited on, and then updated.

Example usage:

// ... create a wait set and a Waitable
// Add the Waitable to the wait set
bool add_ret = waitable.add_to_wait_set(wait_set);
// ... error handling
// Wait
rcl_ret_t wait_ret = rcl_wait(wait_set);
// ... error handling
// Update the Waitable
waitable.update(wait_set);
// Execute any entities of the Waitable that may be ready
std::shared_ptr<void> data = waitable.take_data();

Implements rclcpp::experimental::SubscriptionIntraProcessBase.

◆ execute()

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
void rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::execute ( std::shared_ptr< void > &  data)
inlinevirtual

Execute data that is passed in.

Before calling this method, the Waitable should be added to a wait set, waited on, and then updated - and the take_data method should be called.

Example usage:

// ... create a wait set and a Waitable
// Add the Waitable to the wait set
bool add_ret = waitable.add_to_wait_set(wait_set);
// ... error handling
// Wait
rcl_ret_t wait_ret = rcl_wait(wait_set);
// ... error handling
// Update the Waitable
waitable.update(wait_set);
// Execute any entities of the Waitable that may be ready
std::shared_ptr<void> data = waitable.take_data();
waitable.execute(data);

Implements rclcpp::experimental::SubscriptionIntraProcessBase.

◆ provide_intra_process_message() [1/2]

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
void rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::provide_intra_process_message ( ConstMessageSharedPtr  message)
inline

◆ provide_intra_process_message() [2/2]

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
void rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::provide_intra_process_message ( MessageUniquePtr  message)
inline

◆ use_take_shared_method()

template<typename MessageT , typename Alloc = std::allocator<void>, typename Deleter = std::default_delete<MessageT>, typename CallbackMessageT = MessageT>
bool rclcpp::experimental::SubscriptionIntraProcess< MessageT, Alloc, Deleter, CallbackMessageT >::use_take_shared_method ( ) const
inlinevirtual

The documentation for this class was generated from the following file:
std::shared_ptr< void >
rcl_ret_t
rmw_ret_t rcl_ret_t
rcl_wait
rcl_ret_t rcl_wait(rcl_wait_set_t *wait_set, int64_t timeout)