-
Notifications
You must be signed in to change notification settings - Fork 27
RSDK-6484 - add reconfigurable base class #212
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #include <viam/sdk/resource/reconfigurable.hpp> | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace viam { | ||
| namespace sdk { | ||
|
|
||
| Reconfigurable::~Reconfigurable() = default; | ||
| Reconfigurable::Reconfigurable() = default; | ||
|
|
||
| void Reconfigurable::reconfigure_if_reconfigurable(const std::shared_ptr<Resource>& resource, | ||
| const Dependencies& deps, | ||
| const ResourceConfig& cfg) { | ||
| auto reconfigurable_res = std::dynamic_pointer_cast<Reconfigurable>(resource); | ||
| if (reconfigurable_res) { | ||
| reconfigurable_res->reconfigure(deps, cfg); | ||
| } | ||
| } | ||
|
|
||
| } // namespace sdk | ||
| } // namespace viam | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #pragma once | ||
|
|
||
| #include <viam/sdk/config/resource.hpp> | ||
| #include <viam/sdk/resource/resource.hpp> | ||
|
|
||
| namespace viam { | ||
| namespace sdk { | ||
|
|
||
| class Reconfigurable { | ||
| public: | ||
| virtual ~Reconfigurable(); | ||
|
|
||
| /// @brief Reconfigures a resource. | ||
| /// @param deps Dependencies of the resource. | ||
| /// @param cfg The resource's config. | ||
| virtual void reconfigure(const Dependencies& deps, const ResourceConfig& cfg) = 0; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opted to change the signature of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is fine. |
||
|
|
||
| /// @brief Reconfigures a resource if it is Reconfigurable. | ||
| /// @param resource the Resource to reconfigure. | ||
| /// @param deps Dependencies of the resource. | ||
| /// @param cfg The resource's config. | ||
| static void reconfigure_if_reconfigurable(const std::shared_ptr<Resource>& resource, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we discussed this before or not, but I wonder if you could just make this a non-virtual method of Same could be done for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this, it seems nice to have One clarifying point/question, I believe the methods will have to be
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, sorry - I hadn't really focused on the fact that it took a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only thing that maybe bugs me about my proposal is that having
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool sounds good, I'll make a ticket for revisiting. |
||
| const Dependencies& deps, | ||
| const ResourceConfig& cfg); | ||
|
|
||
| protected: | ||
| explicit Reconfigurable(); | ||
| }; | ||
|
|
||
| } // namespace sdk | ||
| } // namespace viam | ||
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.
The "associated" include should always be first, in a standalone block.
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.
Oops, missed this! Thanks for the catch :)