Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rcl_publisher_get_non_local_subscription_count #1111

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions rcl/include/rcl/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,33 @@ rcl_publisher_get_subscription_count(
const rcl_publisher_t * publisher,
size_t * subscription_count);

/// Get the number of non local subscriptions matched to a publisher.
/**
* Used to get the internal count of non local subscriptions matched to a publisher.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | Maybe [1]
* Lock-Free | Maybe [1]
* <i>[1] only if the underlying rmw doesn't make use of this feature </i>
*
* \param[in] publisher pointer to the rcl publisher
* \param[out] non_local_subscription_count number of non local matched subscriptions
* \return #RCL_RET_OK if the count was retrieved, or
* \return #RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
* \return #RCL_RET_PUBLISHER_INVALID if the publisher is invalid, or
* \return #RCL_RET_ERROR if an unspecified error occurs.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_publisher_get_non_local_subscription_count(
const rcl_publisher_t * publisher,
size_t * non_local_subscription_count);

/// Get the actual qos settings of the publisher.
/**
* Used to get the actual qos settings of the publisher.
Expand Down
20 changes: 20 additions & 0 deletions rcl/src/rcl/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,26 @@ rcl_publisher_get_subscription_count(
return RCL_RET_OK;
}

rcl_ret_t
rcl_publisher_get_non_local_subscription_count(
const rcl_publisher_t * publisher,
size_t * non_local_subscription_count)
{
if (!rcl_publisher_is_valid(publisher)) {
return RCL_RET_PUBLISHER_INVALID;
}
RCL_CHECK_ARGUMENT_FOR_NULL(non_local_subscription_count, RCL_RET_INVALID_ARGUMENT);

rmw_ret_t ret = rmw_publisher_count_non_local_matched_subscriptions(
publisher->impl->rmw_handle, non_local_subscription_count);

if (ret != RMW_RET_OK) {
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
return rcl_convert_rmw_ret_to_rcl_ret(ret);
}
return RCL_RET_OK;
}

const rmw_qos_profile_t *
rcl_publisher_get_actual_qos(const rcl_publisher_t * publisher)
{
Expand Down