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::intra_process_manager::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...
 
const rmw_gid_tget_intra_process_gid () const
 Get the global identifier for this publisher used by intra-process communication. 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...
 
rmw_qos_profile_t get_actual_qos () const
 Get the actual QoS settings, after the defaults have been determined. 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...
 
virtual mapped_ring_buffer::MappedRingBufferBase::SharedPtr make_mapped_ring_buffer (size_t size) const
 Implementation utility function that creates a typed mapped ring buffer. More...
 
void setup_intra_process (uint64_t intra_process_publisher_id, IntraProcessManagerSharedPtr ipm, const rcl_publisher_options_t &intra_process_options)
 Implementation utility function used to setup intra process publishing after creation. More...
 

Protected Types

using IntraProcessManagerWeakPtr = std::weak_ptr< rclcpp::intra_process_manager::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()
 
rcl_publisher_t intra_process_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_
 
rmw_gid_t intra_process_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_intra_process_gid()

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

Get the global identifier for this publisher used by intra-process communication.

Returns
The intra-process 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()

rmw_qos_profile_t 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.

◆ 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.

◆ make_mapped_ring_buffer()

virtual mapped_ring_buffer::MappedRingBufferBase::SharedPtr rclcpp::PublisherBase::make_mapped_ring_buffer ( size_t  size) const
virtual

Implementation utility function that creates a typed mapped ring buffer.

Reimplemented in rclcpp::Publisher< MessageT, Alloc >, and rclcpp::Publisher< rcl_interfaces::msg::ParameterEvent >.

◆ setup_intra_process()

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

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

◆ intra_process_publisher_handle_

rcl_publisher_t rclcpp::PublisherBase::intra_process_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

◆ intra_process_rmw_gid_

rmw_gid_t rclcpp::PublisherBase::intra_process_rmw_gid_
protected

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