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

Get node names and namespaces #545

Merged
merged 3 commits into from
Sep 6, 2018
Merged

Conversation

mjcarroll
Copy link
Member

Add a new method to return a vector of pair to get both node names and namespaces.

Connects to ros2/rmw#142

@mjcarroll mjcarroll added the in progress Actively being worked on (Kanban column) label Aug 29, 2018
if (ret != RCL_RET_OK) {
auto error_msg = std::string("failed to get node names: ") + rcl_get_error_string_safe();
rcl_reset_error();
if (rcutils_string_array_fini(&node_names_c) != RCUTILS_RET_OK) {
error_msg += std::string(", failed also to cleanup node names, leaking memory: ") +
rcl_get_error_string_safe();
}
if (rcutils_string_array_fini(&node_namespaces_c) != RCUTILS_RET_OK) {
error_msg += std::string(", failed also to cleanup node namespaces, leaking memory: ") +
rcl_get_error_string_safe();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't being done in the existing code either, but you should reset the error with rcl_reset_error().

ret = rcutils_string_array_fini(&node_namespaces_c);
if (ret != RCUTILS_RET_OK) {
// *INDENT-OFF*
// TODO(karsten1987): Append rcutils_error_message once it's in master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this TODO (copied here or from the original) @Karsten1987 can you explain?

@@ -163,10 +183,19 @@ NodeGraph::get_node_names() const
std::string("could not destroy node names: "));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception should only be thrown after trying to fini the node_namespaces_c struct as well.


return node_names;
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Seems like unnecessary vertical whitepsace (https://google.github.io/styleguide/cppguide.html#Vertical_Whitespace)

@mjcarroll mjcarroll merged commit 8c6f38a into master Sep 6, 2018
@mjcarroll mjcarroll deleted the get_node_names_and_namespaces branch September 6, 2018 13:02
@mjcarroll mjcarroll removed the in progress Actively being worked on (Kanban column) label Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants