-
Notifications
You must be signed in to change notification settings - Fork 26
RSDK-6627 - move resource-names-for-resource to be a method on resource #222
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
RSDK-6627 - move resource-names-for-resource to be a method on resource #222
Conversation
acmorrow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to keep this to pure code motion to limit scope then LGTM. If you are willing to put a few more minutes into it, I think it'd be nice to see a doc comment, and maybe bikeshed the name of the function? I'm a little unclear on what it is intended to do.
src/viam/sdk/resource/resource.hpp
Outdated
| /// @brief Return the resource's name. | ||
| virtual std::string name() const; | ||
|
|
||
| std::vector<Name> resource_names() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's please add a doc comment for this while we are moving it.
Also, is resource_names the best name for this method? I'm actually a little unclear on what the meaning of the returned names is. It seems to be all the registered models that share the same API as this resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Though, it appears the only place this method is ever used is on a private method in RobotService. I wonder if it might make sense to just have this be a private method and make RobotService a friend class?
src/viam/sdk/robot/service.cpp
Outdated
| for (const auto& key_and_val : resource_manager()->resources()) { | ||
| for (const Name& resource : resource_names_for_resource(key_and_val.second)) { | ||
| metadata.push_back(resource.to_proto()); | ||
| for (const Name& name : key_and_val.second->registered_models()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is really the only usage of registered_models, I'd suggest just moving the function into this file in the unnamed namespace and changing it to take a const Resource&
acmorrow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
purplenicole730
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 😁
No description provided.