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

#include <publisher_base.hpp>

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

Public Types

using IntraProcessManagerSharedPtr = std::shared_ptr< rclcpp::experimental::IntraProcessManager >
 

Public Member Functions

 PublisherBase (rclcpp::node_interfaces::NodeBaseInterface *node_base, const std::string &topic, const rosidl_message_type_support_t &type_support, const rcl_publisher_options_t &publisher_options)
 Default constructor. More...
 
virtual ~PublisherBase ()
 
const char * get_topic_name () const
 Get the topic that this publisher publishes on. More...
 
size_t get_queue_size () const
 Get the queue size for this publisher. More...
 
const rmw_gid_tget_gid () const
 Get the global identifier for this publisher (used in rmw and by DDS). More...
 
rcl_publisher_tget_publisher_handle ()
 Get the rcl publisher handle. More...
 
const rcl_publisher_tget_publisher_handle () const
 Get the rcl publisher handle. More...
 
const std::vector< std::shared_ptr< rclcpp::QOSEventHandlerBase > > & get_event_handlers () const
 Get all the QoS event handlers associated with this publisher. More...
 
size_t get_subscription_count () const
 Get subscription count. More...
 
size_t get_intra_process_subscription_count () const
 Get intraprocess subscription count. More...
 
RCUTILS_WARN_UNUSED bool assert_liveliness () const
 Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC). More...
 
rclcpp::QoS get_actual_qos () const
 Get the actual QoS settings, after the defaults have been determined. More...
 
bool can_loan_messages () const
 Check if publisher instance can loan messages. More...
 
bool operator== (const rmw_gid_t &gid) const
 Compare this publisher to a gid. More...
 
bool operator== (const rmw_gid_t *gid) const
 Compare this publisher to a pointer gid. More...
 
void setup_intra_process (uint64_t intra_process_publisher_id, IntraProcessManagerSharedPtr ipm)
 Implementation utility function used to setup intra process publishing after creation. More...
 
- Public Member Functions inherited from std::enable_shared_from_this< PublisherBase >
enable_shared_from_this (T... args)
 
operator= (T... args)
 
shared_from_this (T... args)
 
~enable_shared_from_this (T... args)
 

Protected Types

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

Protected Member Functions

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

Protected Attributes

std::shared_ptr< rcl_node_trcl_node_handle_
 
rcl_publisher_t publisher_handle_ = rcl_get_zero_initialized_publisher()
 
std::vector< std::shared_ptr< rclcpp::QOSEventHandlerBase > > event_handlers_
 
bool intra_process_is_enabled_
 
IntraProcessManagerWeakPtr weak_ipm_
 
uint64_t intra_process_publisher_id_
 
rmw_gid_t rmw_gid_
 

Member Typedef Documentation

◆ IntraProcessManagerSharedPtr

◆ IntraProcessManagerWeakPtr

Constructor & Destructor Documentation

◆ PublisherBase()

rclcpp::PublisherBase::PublisherBase ( rclcpp::node_interfaces::NodeBaseInterface node_base,
const std::string topic,
const rosidl_message_type_support_t &  type_support,
const rcl_publisher_options_t publisher_options 
)

Default constructor.

Typically, a publisher is not created through this method, but instead is created through a call to Node::create_publisher.

Parameters
[in]node_baseA pointer to the NodeBaseInterface for the parent node.
[in]topicThe topic that this publisher publishes on.
[in]type_supportThe type support structure for the type to be published.
[in]publisher_optionsQoS settings for this publisher.

◆ ~PublisherBase()

virtual rclcpp::PublisherBase::~PublisherBase ( )
virtual

Member Function Documentation

◆ get_topic_name()

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

Get the topic that this publisher publishes on.

Returns
The topic name.

◆ get_queue_size()

size_t rclcpp::PublisherBase::get_queue_size ( ) const

Get the queue size for this publisher.

Returns
The queue size.

◆ get_gid()

const rmw_gid_t& rclcpp::PublisherBase::get_gid ( ) const

Get the global identifier for this publisher (used in rmw and by DDS).

Returns
The gid.

◆ get_publisher_handle() [1/2]

rcl_publisher_t* rclcpp::PublisherBase::get_publisher_handle ( )

Get the rcl publisher handle.

Returns
The rcl publisher handle.

◆ get_publisher_handle() [2/2]

const rcl_publisher_t* rclcpp::PublisherBase::get_publisher_handle ( ) const

Get the rcl publisher handle.

Returns
The rcl publisher handle.

◆ get_event_handlers()

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

Get all the QoS event handlers associated with this publisher.

Returns
The vector of QoS event handlers.

◆ get_subscription_count()

size_t rclcpp::PublisherBase::get_subscription_count ( ) const

Get subscription count.

Returns
The number of subscriptions.

◆ get_intra_process_subscription_count()

size_t rclcpp::PublisherBase::get_intra_process_subscription_count ( ) const

Get intraprocess subscription count.

Returns
The number of intraprocess subscriptions.

◆ assert_liveliness()

RCUTILS_WARN_UNUSED bool rclcpp::PublisherBase::assert_liveliness ( ) const

Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC).

If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC, the creator of this publisher may manually call assert_liveliness at some point in time to signal to the rest of the system that this Node is still alive.

Returns
true if the liveliness was asserted successfully, otherwise false

◆ get_actual_qos()

rclcpp::QoS rclcpp::PublisherBase::get_actual_qos ( ) const

Get the actual QoS settings, after the defaults have been determined.

The actual configuration applied when using RMW_QOS_POLICY_*_SYSTEM_DEFAULT can only be resolved after the creation of the publisher, and it depends on the underlying rmw implementation. If the underlying setting in use can't be represented in ROS terms, it will be set to RMW_QOS_POLICY_*_UNKNOWN. May throw runtime_error when an unexpected error occurs.

Returns
The actual qos settings.

◆ can_loan_messages()

bool rclcpp::PublisherBase::can_loan_messages ( ) const

Check if publisher instance can loan messages.

Depending on the middleware and the message type, this will return true if the middleware can allocate a ROS message instance.

◆ operator==() [1/2]

bool rclcpp::PublisherBase::operator== ( const rmw_gid_t gid) const

Compare this publisher to a gid.

Note that this function calls the next function.

Parameters
[in]gidReference to a gid.
Returns
True if the publisher's gid matches the input.

◆ operator==() [2/2]

bool rclcpp::PublisherBase::operator== ( const rmw_gid_t gid) const

Compare this publisher to a pointer gid.

A wrapper for comparing this publisher's gid to the input using rmw_compare_gids_equal.

Parameters
[in]gidA pointer to a gid.
Returns
True if this publisher's gid matches the input.

◆ setup_intra_process()

void rclcpp::PublisherBase::setup_intra_process ( uint64_t  intra_process_publisher_id,
IntraProcessManagerSharedPtr  ipm 
)

Implementation utility function used to setup intra process publishing after creation.

◆ add_event_handler()

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

Member Data Documentation

◆ rcl_node_handle_

std::shared_ptr<rcl_node_t> rclcpp::PublisherBase::rcl_node_handle_
protected

◆ publisher_handle_

rcl_publisher_t rclcpp::PublisherBase::publisher_handle_ = rcl_get_zero_initialized_publisher()
protected

◆ event_handlers_

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

◆ intra_process_is_enabled_

bool rclcpp::PublisherBase::intra_process_is_enabled_
protected

◆ weak_ipm_

IntraProcessManagerWeakPtr rclcpp::PublisherBase::weak_ipm_
protected

◆ intra_process_publisher_id_

uint64_t rclcpp::PublisherBase::intra_process_publisher_id_
protected

◆ rmw_gid_

rmw_gid_t rclcpp::PublisherBase::rmw_gid_
protected

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