-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sq: Lifecycle Separation of Concerns
Signed-off-by: Tom Groechel <tgroeche@umich.edu>
- Loading branch information
Showing
13 changed files
with
1,132 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2016 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
#include "lifecycle_node_entities_manager.hpp" | ||
|
||
namespace rclcpp_lifecycle | ||
{ | ||
|
||
void | ||
LifecycleNodeEntitiesManager::on_activate() const | ||
{ | ||
for (const auto & weak_entity : weak_managed_entities_) { | ||
auto entity = weak_entity.lock(); | ||
if (entity) { | ||
entity->on_activate(); | ||
} | ||
} | ||
} | ||
|
||
void | ||
LifecycleNodeEntitiesManager::on_deactivate() const | ||
{ | ||
for (const auto & weak_entity : weak_managed_entities_) { | ||
auto entity = weak_entity.lock(); | ||
if (entity) { | ||
entity->on_deactivate(); | ||
} | ||
} | ||
} | ||
|
||
void | ||
LifecycleNodeEntitiesManager::add_managed_entity( | ||
std::weak_ptr<rclcpp_lifecycle::ManagedEntityInterface> managed_entity) | ||
{ | ||
weak_managed_entities_.push_back(managed_entity); | ||
} | ||
|
||
void | ||
LifecycleNodeEntitiesManager::add_timer_handle( | ||
std::shared_ptr<rclcpp::TimerBase> timer) | ||
{ | ||
weak_timers_.push_back(timer); | ||
} | ||
|
||
} // namespace rclcpp_lifecycle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2023 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef LIFECYCLE_NODE_ENTITIES_MANAGER_HPP_ | ||
#define LIFECYCLE_NODE_ENTITIES_MANAGER_HPP_ | ||
|
||
#include <vector> | ||
#include <memory> | ||
#include "rclcpp_lifecycle/managed_entity.hpp" | ||
#include <rclcpp/timer.hpp> | ||
|
||
namespace rclcpp_lifecycle | ||
{ | ||
|
||
class LifecycleNodeEntitiesManager | ||
{ | ||
public: | ||
void | ||
on_activate() const; | ||
|
||
void | ||
on_deactivate() const; | ||
|
||
void | ||
add_managed_entity(std::weak_ptr<rclcpp_lifecycle::ManagedEntityInterface> managed_entity); | ||
|
||
void | ||
add_timer_handle(std::shared_ptr<rclcpp::TimerBase> timer); | ||
|
||
private: | ||
std::vector<std::weak_ptr<rclcpp_lifecycle::ManagedEntityInterface>> weak_managed_entities_; | ||
std::vector<std::weak_ptr<rclcpp::TimerBase>> weak_timers_; | ||
}; | ||
|
||
} // namespace rclcpp_lifecycle | ||
#endif // LIFECYCLE_NODE_ENTITIES_MANAGER_HPP_ |
Oops, something went wrong.