rclcpp  master
C++ ROS Client Library API
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rclcpp::SubscriptionBase Class Referenceabstract

#include <subscription_base.hpp>

Inheritance diagram for rclcpp::SubscriptionBase:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::SubscriptionBase:
Collaboration graph
[legend]

Public Types

using IntraProcessManagerWeakPtr = std::weak_ptr< rclcpp::intra_process_manager::IntraProcessManager >
 

Public Member Functions

 SubscriptionBase (std::shared_ptr< rcl_node_t > node_handle, const rosidl_message_type_support_t &type_support_handle, const std::string &topic_name, const rcl_subscription_options_t &subscription_options, bool is_serialized=false)
 Default constructor. More...
 
virtual ~SubscriptionBase ()
 Default destructor. More...
 
const char * get_topic_name () const
 Get the topic that this subscription is subscribed on. More...
 
std::shared_ptr< rcl_subscription_tget_subscription_handle ()
 
const std::shared_ptr< rcl_subscription_tget_subscription_handle () const
 
virtual const std::shared_ptr< rcl_subscription_tget_intra_process_subscription_handle () const
 
const std::vector< std::shared_ptr< rclcpp::QOSEventHandlerBase > > & get_event_handlers () const
 Get all the QoS event handlers associated with this subscription. More...
 
virtual std::shared_ptr< void > create_message ()=0
 Borrow a new message. More...
 
virtual std::shared_ptr< rcl_serialized_message_tcreate_serialized_message ()=0
 Borrow a new serialized message. More...
 
virtual void handle_message (std::shared_ptr< void > &message, const rmw_message_info_t &message_info)=0
 Check if we need to handle the message, and execute the callback if we do. More...
 
virtual void return_message (std::shared_ptr< void > &message)=0
 Return the message borrowed in create_message. More...
 
virtual void return_serialized_message (std::shared_ptr< rcl_serialized_message_t > &message)=0
 Return the message borrowed in create_serialized_message. More...
 
virtual void handle_intra_process_message (rcl_interfaces::msg::IntraProcessMessage &ipm, const rmw_message_info_t &message_info)=0
 
const rosidl_message_type_support_t & get_message_type_support_handle () const
 
bool is_serialized () const
 
size_t get_publisher_count () const
 Get matching publisher count. More...
 
void setup_intra_process (uint64_t intra_process_subscription_id, IntraProcessManagerWeakPtr weak_ipm, const rcl_subscription_options_t &intra_process_options)
 Implemenation detail. More...
 

Protected Member Functions

template<typename EventCallbackT >
void add_event_handler (const EventCallbackT &callback, const rcl_subscription_event_type_t event_type)
 

Protected Attributes

std::shared_ptr< rcl_node_tnode_handle_
 
std::shared_ptr< rcl_subscription_tsubscription_handle_
 
std::shared_ptr< rcl_subscription_tintra_process_subscription_handle_
 
std::vector< std::shared_ptr< rclcpp::QOSEventHandlerBase > > event_handlers_
 
bool use_intra_process_
 
IntraProcessManagerWeakPtr weak_ipm_
 
uint64_t intra_process_subscription_id_
 

Detailed Description

Virtual base class for subscriptions. This pattern allows us to iterate over different template specializations of Subscription, among other things.

Member Typedef Documentation

◆ IntraProcessManagerWeakPtr

Constructor & Destructor Documentation

◆ SubscriptionBase()

rclcpp::SubscriptionBase::SubscriptionBase ( std::shared_ptr< rcl_node_t node_handle,
const rosidl_message_type_support_t &  type_support_handle,
const std::string topic_name,
const rcl_subscription_options_t subscription_options,
bool  is_serialized = false 
)

Default constructor.

Parameters
[in]node_handleThe rcl representation of the node that owns this subscription.
[in]type_support_handlerosidl type support struct, for the Message type of the topic.
[in]topic_nameName of the topic to subscribe to.
[in]subscription_optionsoptions for the subscription.
[in]is_serializedis true if the message will be delivered still serialized

◆ ~SubscriptionBase()

virtual rclcpp::SubscriptionBase::~SubscriptionBase ( )
virtual

Default destructor.

Member Function Documentation

◆ get_topic_name()

const char* rclcpp::SubscriptionBase::get_topic_name ( ) const

Get the topic that this subscription is subscribed on.

◆ get_subscription_handle() [1/2]

std::shared_ptr<rcl_subscription_t> rclcpp::SubscriptionBase::get_subscription_handle ( )

◆ get_subscription_handle() [2/2]

const std::shared_ptr<rcl_subscription_t> rclcpp::SubscriptionBase::get_subscription_handle ( ) const

◆ get_intra_process_subscription_handle()

virtual const std::shared_ptr<rcl_subscription_t> rclcpp::SubscriptionBase::get_intra_process_subscription_handle ( ) const
virtual

◆ get_event_handlers()

const std::vector<std::shared_ptr<rclcpp::QOSEventHandlerBase> >& rclcpp::SubscriptionBase::get_event_handlers ( ) const

Get all the QoS event handlers associated with this subscription.

Returns
The vector of QoS event handlers.

◆ create_message()

virtual std::shared_ptr<void> rclcpp::SubscriptionBase::create_message ( )
pure virtual

Borrow a new message.

Returns
Shared pointer to the fresh message.

Implemented in rclcpp::Subscription< CallbackMessageT, Alloc >.

◆ create_serialized_message()

virtual std::shared_ptr<rcl_serialized_message_t> rclcpp::SubscriptionBase::create_serialized_message ( )
pure virtual

Borrow a new serialized message.

Returns
Shared pointer to a rcl_message_serialized_t.

Implemented in rclcpp::Subscription< CallbackMessageT, Alloc >.

◆ handle_message()

virtual void rclcpp::SubscriptionBase::handle_message ( std::shared_ptr< void > &  message,
const rmw_message_info_t message_info 
)
pure virtual

Check if we need to handle the message, and execute the callback if we do.

Parameters
[in]messageShared pointer to the message to handle.
[in]message_infoMetadata associated with this message.

Implemented in rclcpp::Subscription< CallbackMessageT, Alloc >.

◆ return_message()

virtual void rclcpp::SubscriptionBase::return_message ( std::shared_ptr< void > &  message)
pure virtual

Return the message borrowed in create_message.

Parameters
[in]messageShared pointer to the returned message.

Implemented in rclcpp::Subscription< CallbackMessageT, Alloc >.

◆ return_serialized_message()

virtual void rclcpp::SubscriptionBase::return_serialized_message ( std::shared_ptr< rcl_serialized_message_t > &  message)
pure virtual

Return the message borrowed in create_serialized_message.

Parameters
[in]messageShared pointer to the returned message.

Implemented in rclcpp::Subscription< CallbackMessageT, Alloc >.

◆ handle_intra_process_message()

virtual void rclcpp::SubscriptionBase::handle_intra_process_message ( rcl_interfaces::msg::IntraProcessMessage &  ipm,
const rmw_message_info_t message_info 
)
pure virtual

◆ get_message_type_support_handle()

const rosidl_message_type_support_t& rclcpp::SubscriptionBase::get_message_type_support_handle ( ) const

◆ is_serialized()

bool rclcpp::SubscriptionBase::is_serialized ( ) const

◆ get_publisher_count()

size_t rclcpp::SubscriptionBase::get_publisher_count ( ) const

Get matching publisher count.

Returns
The number of publishers on this topic.

◆ setup_intra_process()

void rclcpp::SubscriptionBase::setup_intra_process ( uint64_t  intra_process_subscription_id,
IntraProcessManagerWeakPtr  weak_ipm,
const rcl_subscription_options_t intra_process_options 
)

Implemenation detail.

◆ add_event_handler()

template<typename EventCallbackT >
void rclcpp::SubscriptionBase::add_event_handler ( const EventCallbackT &  callback,
const rcl_subscription_event_type_t  event_type 
)
inlineprotected

Member Data Documentation

◆ node_handle_

std::shared_ptr<rcl_node_t> rclcpp::SubscriptionBase::node_handle_
protected

◆ subscription_handle_

std::shared_ptr<rcl_subscription_t> rclcpp::SubscriptionBase::subscription_handle_
protected

◆ intra_process_subscription_handle_

std::shared_ptr<rcl_subscription_t> rclcpp::SubscriptionBase::intra_process_subscription_handle_
protected

◆ event_handlers_

std::vector<std::shared_ptr<rclcpp::QOSEventHandlerBase> > rclcpp::SubscriptionBase::event_handlers_
protected

◆ use_intra_process_

bool rclcpp::SubscriptionBase::use_intra_process_
protected

◆ weak_ipm_

IntraProcessManagerWeakPtr rclcpp::SubscriptionBase::weak_ipm_
protected

◆ intra_process_subscription_id_

uint64_t rclcpp::SubscriptionBase::intra_process_subscription_id_
protected

The documentation for this class was generated from the following file: