Skip to content

Commit c3b7077

Browse files
authored
Methods to retrieve matched counts on publisher and subscriber (#155)
* Methods to retrieve matched counts on pub/sub. * Address reviewer feedback with naming and docs. * Fix typos. * Apply suggestions from code review Co-Authored-By: mjcarroll <[email protected]>
1 parent 146052a commit c3b7077

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

rmw/include/rmw/rmw.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ RMW_WARN_UNUSED
188188
rmw_ret_t
189189
rmw_publish(const rmw_publisher_t * publisher, const void * ros_message);
190190

191+
/// Retrieve the number of matched subscriptions to a publisher.
192+
/**
193+
* Query the underlying middleware to determine how many subscriptions are
194+
* matched to a given publisher.
195+
*
196+
* \param[in] publisher the publisher object to inspect
197+
* \param[out] subscription_count the number of subscriptions matched
198+
* \return `RMW_RET_OK` if successful, or
199+
* \return `RMW_RET_INVALID_ARGUMENT` if either argument is null, or
200+
* \return `RMW_RET_ERROR` if an unexpected error occurs.
201+
*/
202+
RMW_PUBLIC
203+
RMW_WARN_UNUSED
204+
rmw_ret_t
205+
rmw_publisher_count_matched_subscriptions(
206+
const rmw_publisher_t * publisher,
207+
size_t * subscription_count);
208+
191209
/// Publish an already serialized message.
192210
/**
193211
* The publisher must already be registered with the correct message type
@@ -267,6 +285,24 @@ RMW_WARN_UNUSED
267285
rmw_ret_t
268286
rmw_destroy_subscription(rmw_node_t * node, rmw_subscription_t * subscription);
269287

288+
/// Retrieve the number of matched publishers to a subscription.
289+
/**
290+
* Query the underlying middleware to determine how many publishers are
291+
* matched to a given subscription.
292+
*
293+
* \param[in] subscription the subscription object to inspect
294+
* \param[out] publisher_count the number of publishers matched
295+
* \return `RMW_RET_OK` if successful, or
296+
* \return `RMW_RET_INVALID_ARGUMENT` if either argument is null, or
297+
* \return `RMW_RET_ERROR` if an unexpected error occurs.
298+
*/
299+
RMW_PUBLIC
300+
RMW_WARN_UNUSED
301+
rmw_ret_t
302+
rmw_subscription_count_matched_publishers(
303+
const rmw_subscription_t * subscription,
304+
size_t * publisher_count);
305+
270306
RMW_PUBLIC
271307
RMW_WARN_UNUSED
272308
rmw_ret_t

0 commit comments

Comments
 (0)