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

add : get clients,servers info #154

Open
wants to merge 2 commits 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
26 changes: 26 additions & 0 deletions rmw_connextdds/src/rmw_api_impl_ndds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,32 @@ rmw_get_subscriptions_info_by_topic(
node, allocator, topic_name, no_mangle, subscriptions_info);
}


rmw_ret_t
rmw_get_clients_info_by_service(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * service_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * clients_info)
{
return rmw_api_connextdds_get_clients_info_by_service(
node, allocator, service_name, no_mangle, clients_info);
}


rmw_ret_t
rmw_get_servers_info_by_service(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * service_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * servers_info)
{
return rmw_api_connextdds_get_servers_info_by_service(
node, allocator, service_name, no_mangle, servers_info);
}

/*****************************************************************************
* Node API
*****************************************************************************/
Expand Down
18 changes: 18 additions & 0 deletions rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,24 @@ rmw_api_connextdds_get_subscriptions_info_by_topic(
bool no_mangle,
rmw_topic_endpoint_info_array_t * subscriptions_info);

RMW_CONNEXTDDS_PUBLIC
rmw_ret_t
rmw_api_connextdds_get_clients_info_by_service(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * service_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * clients_info);

RMW_CONNEXTDDS_PUBLIC
rmw_ret_t
rmw_api_connextdds_get_servers_info_by_service(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * service_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * servers_info);

/*****************************************************************************
* Node API
*****************************************************************************/
Expand Down
84 changes: 84 additions & 0 deletions rmw_connextdds_common/src/common/rmw_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,3 +670,87 @@ rmw_api_connextdds_get_subscriptions_info_by_topic(
allocator,
subscriptions_info);
}


rmw_ret_t
rmw_api_connextdds_get_clients_info_by_service(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * service_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * clients_info)
{
RMW_CHECK_ARGUMENT_FOR_NULL(node, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
node,
node->implementation_identifier,
RMW_CONNEXTDDS_ID,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(allocator, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(service_name, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(clients_info, RMW_RET_INVALID_ARGUMENT);

RCUTILS_CHECK_ALLOCATOR_WITH_MSG(
allocator, "allocator argument is invalid", return RMW_RET_INVALID_ARGUMENT);

if (RMW_RET_OK != rmw_topic_endpoint_info_array_check_zero(clients_info)) {
return RMW_RET_INVALID_ARGUMENT;
}

auto common_context = &node->context->impl->common;
std::string mangled_rp_topic_name = service_name;
DemangleFunction demangle_type = _identity_demangle;
if (!no_mangle) {
mangled_rp_topic_name =
rmw_connextdds_create_topic_name(
ROS_SERVICE_RESPONSE_PREFIX, service_name, "Reply", false);
demangle_type = _demangle_if_ros_type;
}
return common_context->graph_cache.get_readers_info_by_topic(
mangled_rp_topic_name,
demangle_type,
allocator,
clients_info);
}


rmw_ret_t
rmw_api_connextdds_get_servers_info_by_service(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * service_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * servers_info)
{
RMW_CHECK_ARGUMENT_FOR_NULL(node, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
node,
node->implementation_identifier,
RMW_CONNEXTDDS_ID,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(allocator, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(service_name, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(servers_info, RMW_RET_INVALID_ARGUMENT);

RCUTILS_CHECK_ALLOCATOR_WITH_MSG(
allocator, "allocator argument is invalid", return RMW_RET_INVALID_ARGUMENT);

if (RMW_RET_OK != rmw_topic_endpoint_info_array_check_zero(servers_info)) {
return RMW_RET_INVALID_ARGUMENT;
}

auto common_context = &node->context->impl->common;
std::string mangled_rp_topic_name = service_name;
DemangleFunction demangle_type = _identity_demangle;
if (!no_mangle) {
mangled_rp_topic_name =
rmw_connextdds_create_topic_name(
ROS_SERVICE_RESPONSE_PREFIX, service_name, "Reply", false);
demangle_type = _demangle_if_ros_type;
}
return common_context->graph_cache.get_writers_info_by_topic(
mangled_rp_topic_name,
demangle_type,
allocator,
servers_info);
}
25 changes: 25 additions & 0 deletions rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,31 @@ rmw_get_subscriptions_info_by_topic(
node, allocator, topic_name, no_mangle, subscriptions_info);
}


rmw_ret_t
rmw_get_clients_info_by_service(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * service_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * clients_info)
{
return rmw_api_connextdds_get_clients_info_by_service(
node, allocator, service_name, no_mangle, clients_info);
}


rmw_ret_t
rmw_get_servers_info_by_service(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * service_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * servers_info)
{
return rmw_api_connextdds_get_servers_info_by_service(
node, allocator, service_name, no_mangle, servers_info);
}
/*****************************************************************************
* Node API
*****************************************************************************/
Expand Down