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 function for getting clients by node #293

Merged
merged 1 commit into from
Jul 9, 2019
Merged
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
13 changes: 13 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_node_info_and_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ rmw_get_service_names_and_types_by_node(
eprosima_fastrtps_identifier, node, allocator, node_name, node_namespace,
service_names_and_types);
}

rmw_ret_t
rmw_get_client_names_and_types_by_node(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * node_name,
const char * node_namespace,
rmw_names_and_types_t * service_names_and_types)
{
return rmw_fastrtps_shared_cpp::__rmw_get_client_names_and_types_by_node(
eprosima_fastrtps_identifier, node, allocator, node_name, node_namespace,
service_names_and_types);
}
} // extern "C"
17 changes: 17 additions & 0 deletions rmw_fastrtps_dynamic_cpp/src/rmw_node_info_and_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,21 @@ rmw_get_service_names_and_types_by_node(
node_namespace,
service_names_and_types);
}

rmw_ret_t
rmw_get_client_names_and_types_by_node(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * node_name,
const char * node_namespace,
rmw_names_and_types_t * service_names_and_types)
{
return rmw_fastrtps_shared_cpp::__rmw_get_client_names_and_types_by_node(
eprosima_fastrtps_identifier,
node,
allocator,
node_name,
node_namespace,
service_names_and_types);
}
} // extern "C"
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ __rmw_get_service_names_and_types_by_node(
const char * node_namespace,
rmw_names_and_types_t * service_names_and_types);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_get_client_names_and_types_by_node(
const char * identifier,
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * node_name,
const char * node_namespace,
rmw_names_and_types_t * service_names_and_types);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_get_subscriber_names_and_types_by_node(
Expand Down
55 changes: 53 additions & 2 deletions rmw_fastrtps_shared_cpp/src/rmw_node_info_and_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,18 @@ __rmw_get_publisher_names_and_types_by_node(
node_namespace, no_demangle, retrieve_pub_cache, topic_names_and_types);
}

static
rmw_ret_t
__rmw_get_service_names_and_types_by_node(
__get_service_names_and_types_by_node(
const char * identifier,
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * node_name,
const char * node_namespace,
rmw_names_and_types_t * service_names_and_types)
rmw_names_and_types_t * service_names_and_types,
const char * topic_suffix)
{
const std::string topic_suffix_stdstr(topic_suffix);
rmw_ret_t valid_input = __validate_input(identifier, node, allocator, node_name,
node_namespace, service_names_and_types);
if (valid_input != RMW_RET_OK) {
Expand All @@ -420,6 +423,15 @@ __rmw_get_service_names_and_types_by_node(
// not a service
continue;
}
// Check if the topic suffix matches and is at the end of the name
const std::string & topic_name = topic_pair.first;
auto suffix_position = topic_name.rfind(topic_suffix_stdstr);
if (suffix_position == std::string::npos ||
topic_name.length() - suffix_position - topic_suffix_stdstr.length() != 0)
{
continue;
}

for (auto & itt : topic_pair.second) {
std::string service_type = _demangle_service_type_only(itt);
if (!service_type.empty()) {
Expand Down Expand Up @@ -484,4 +496,43 @@ __rmw_get_service_names_and_types_by_node(
} // for each service
return RMW_RET_OK;
}

rmw_ret_t
__rmw_get_service_names_and_types_by_node(
const char * identifier,
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * node_name,
const char * node_namespace,
rmw_names_and_types_t * service_names_and_types)
{
return __get_service_names_and_types_by_node(
identifier,
node,
allocator,
node_name,
node_namespace,
service_names_and_types,
"Request");
}

rmw_ret_t
__rmw_get_client_names_and_types_by_node(
const char * identifier,
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * node_name,
const char * node_namespace,
rmw_names_and_types_t * service_names_and_types)
{
return __get_service_names_and_types_by_node(
identifier,
node,
allocator,
node_name,
node_namespace,
service_names_and_types,
"Reply");
}

} // namespace rmw_fastrtps_shared_cpp