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

Implement functions to get publisher and subcription informations like QoS policies from topic name #336

Merged
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6721292
Simpled test for topic_cache
jaisontj Oct 17, 2019
944e1f3
Moved qos_converter to include/ since it needs to be accessible to
jaisontj Oct 18, 2019
e7a4a7e
- Modified topic_cache to include qos policies
jaisontj Oct 18, 2019
d0ac7e0
Stubs for rmw_get_publishers_info_by_topic and
jaisontj Oct 16, 2019
e640479
Implemented rmw_get_publishers_info_by_topic and
jaisontj Oct 23, 2019
1a80e44
- Addressing code review changes: Using const auto instead of auto
jaisontj Nov 14, 2019
30a2a56
- Alpha sorted cmakelist.txt
jaisontj Nov 16, 2019
dbfe0b4
- Alphasort
jaisontj Nov 16, 2019
04b29c8
- Refactor to accomodate change in rmw_topic_info_set* functions.
jaisontj Nov 22, 2019
af1e536
Refactor to accomodate change of gid from const char * to uint8_t[]
jaisontj Nov 22, 2019
e87e83c
Moved dds_qos_to_rmw_qos from qos_converter to qos.hpp
jaisontj Nov 22, 2019
16fcaed
- Modified topic cache to store participant guid and
jaisontj Nov 23, 2019
fea85a6
- Handled changes in headers from rmw
jaisontj Nov 27, 2019
1a4d9fa
Better error handling.
jaisontj Nov 27, 2019
169f218
fix error handling in _handle_topic_info_fini()
mm318 Dec 11, 2019
36e9718
address PR comments
mm318 Dec 14, 2019
8152876
address PR comments
mm318 Dec 18, 2019
642d9ed
conditionally demangle type name
mm318 Dec 19, 2019
38dec2a
reverse condition for demangling type name
mm318 Dec 28, 2019
c231f14
properly initialize history and history depth in topic info
mm318 Jan 2, 2020
a1a5e79
address more PR comments
mm318 Jan 10, 2020
354cae2
rename *topic_info* to *topic_endpoint_info*
mm318 Jan 10, 2020
1fe66ed
fix formatting
mm318 Jan 10, 2020
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
43 changes: 12 additions & 31 deletions rmw_fastrtps_shared_cpp/src/rmw_get_topic_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,14 @@ _get_topic_fqdns(const char * topic_name, bool no_mangle)
return topic_fqdns;
}

typedef rmw_ret_t (* rmw_topic_info_fini_func_t)(
rmw_topic_info_t * topic_info,
rcutils_allocator_t * allocator);

void
_handle_topic_info_member_fini(
_handle_topic_info_fini(
rmw_topic_info_t * topic_info,
std::string err_msg_title,
rcutils_allocator_t * allocator,
rmw_topic_info_fini_func_t topic_info_fini_member_func)
rcutils_allocator_t * allocator)
{
std::string error_string = err_msg_title + "\n" + rmw_get_error_string().str;
std::string error_string = rmw_get_error_string().str;
rmw_reset_error();
rmw_ret_t ret = topic_info_fini_member_func(topic_info, allocator);
rmw_ret_t ret = rmw_topic_info_fini(topic_info, allocator);
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
if (ret != RMW_RET_OK) {
error_string += rmw_get_error_string().str;
rmw_reset_error();
Expand Down Expand Up @@ -145,15 +139,10 @@ _set_rmw_topic_info(
if (topic_data.participant_guid == participant_guid) {
ret = rmw_topic_info_set_node_name(topic_info, node_name, allocator);
if (ret != RMW_RET_OK) {
_handle_topic_info_member_fini(topic_info, "Failed to set node_name", allocator,
rmw_topic_info_fini_topic_type);
return ret;
}
ret = rmw_topic_info_set_node_namespace(topic_info, node_namespace, allocator);
if (ret != RMW_RET_OK) {
_handle_topic_info_member_fini(topic_info, "Failed to set node_namespace", allocator,
rmw_topic_info_fini_node_name);
_handle_topic_info_member_fini(topic_info, "", allocator, rmw_topic_info_fini_topic_type);
return ret;
}
return ret;
Expand All @@ -169,8 +158,6 @@ _set_rmw_topic_info(
ret = rmw_topic_info_set_node_name(topic_info, "_NODE_NAME_UNKNOWN_", allocator);
}
if (ret != RMW_RET_OK) {
_handle_topic_info_member_fini(topic_info, "Failed to set node_name", allocator,
rmw_topic_info_fini_topic_type);
return ret;
}
// set node namespace
Expand All @@ -181,11 +168,6 @@ _set_rmw_topic_info(
} else {
ret = rmw_topic_info_set_node_namespace(topic_info, "_NODE_NAMESPACE_UNKNOWN_", allocator);
}
if (ret != RMW_RET_OK) {
_handle_topic_info_member_fini(topic_info, "Failed to set node_namespace", allocator,
rmw_topic_info_fini_node_name);
_handle_topic_info_member_fini(topic_info, "", allocator, rmw_topic_info_fini_topic_type);
}
return ret;
}

Expand Down Expand Up @@ -227,7 +209,7 @@ _get_info_by_topic(
const auto & it = topic_name_to_data.find(topic_name);
wjwwood marked this conversation as resolved.
Show resolved Hide resolved
if (it != topic_name_to_data.end()) {
for (const auto & data : it->second) {
rmw_topic_info_t topic_info;
rmw_topic_info_t topic_info = rmw_get_zero_initialized_topic_info();
rmw_ret_t ret = _set_rmw_topic_info(
&topic_info,
participant_guid,
Expand All @@ -237,17 +219,12 @@ _get_info_by_topic(
slave_target,
allocator);
if (ret != RMW_RET_OK) {
// Free topic_info
_handle_topic_info_fini(&topic_info, allocator);
// Free all the space allocated to the previous topic_infos
for (auto & tinfo : topic_info_vector) {
_handle_topic_info_member_fini(&tinfo, "", allocator,
rmw_topic_info_fini_node_namespace);
_handle_topic_info_member_fini(&tinfo, "", allocator, rmw_topic_info_fini_node_name);
_handle_topic_info_member_fini(&tinfo, "", allocator, rmw_topic_info_fini_topic_type);
_handle_topic_info_fini(&tinfo, allocator);
}
std::string error_msg = "Failed to create set_rmw_topic_info: ";
error_msg += rmw_get_error_string().str;
rmw_reset_error();
RMW_SET_ERROR_MSG(error_msg.c_str());
return ret;
}
// add rmw_topic_info_t to a vector
Expand All @@ -264,6 +241,10 @@ _get_info_by_topic(
rmw_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"rmw_topic_info_array_init_with_size failed to allocate memory: %s", error_message.str);
jaisontj marked this conversation as resolved.
Show resolved Hide resolved
// Free all the space allocated to the previous topic_infos
for (auto & tinfo : topic_info_vector) {
_handle_topic_info_fini(&tinfo, allocator);
}
return RMW_RET_BAD_ALLOC;
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
}
for (auto i = 0u; i < count; i++) {
Expand Down