Class Activator
Defined in File Activator.hpp
Class Documentation
-
class Activator
A factory for generating Task::Active instances from requests.
Public Types
-
template<typename Description>
using Activate = std::function<Task::ActivePtr(const std::function<State()> &get_state, const ConstParametersPtr ¶meters, const Task::ConstBookingPtr &booking, const Description &description, std::optional<std::string> backup_state, std::function<void(Phase::ConstSnapshotPtr)> update, std::function<void(Task::Active::Backup)> checkpoint, std::function<void(Phase::ConstCompletedPtr)> phase_finished, std::function<void()> task_finished)> Signature for activating a task
- Template Parameters:
Description – A class that implements the Task::Description interface
- Param get_state:
[in] A callback for retrieving the current state of the robot
- Param parameters:
[in] A reference to the parameters for the robot
- Param booking:
[in] An immutable reference to the booking information for the task
- Param description:
[in] The down-casted description of the task
- Param backup_state:
[in] The serialized backup state of the Task, if the Task is being restored from a crash or disconnection. If the Task is not being restored, a std::nullopt will be passed in here.
- Param update:
[in] A callback that will be triggered when the task has a significant update in its status.
- Param checkpoint:
[in] A callback that will be triggered when the task has reached a task checkpoint whose state is worth backing up.
- Param finished:
[in] A callback that will be triggered when the task has finished.
- Return:
an active, running instance of the requested task.
Public Functions
-
Activator()
Construct an empty TaskFactory.
-
template<typename Description>
void add_activator(Activate<Description> activator) Add a callback to convert from a Description into an active Task.
- Template Parameters:
Description – A class that implements the Request::Description interface
- Parameters:
activator – [in] A callback that activates a Task matching the Description
-
Task::ActivePtr activate(const std::function<State()> &get_state, const ConstParametersPtr ¶meters, const Request &request, std::function<void(Phase::ConstSnapshotPtr)> update, std::function<void(Task::Active::Backup)> checkpoint, std::function<void(Phase::ConstCompletedPtr)> phase_finished, std::function<void()> task_finished) const
Activate a Task object based on a Request.
- Parameters:
get_state – [in] A callback for retrieving the current state of the robot
parameters – [in] A reference to the parameters for the robot
request – [in] The task request
update – [in] A callback that will be triggered when the task has a significant update
checkpoint – [in] A callback that will be triggered when the task has reached a task checkpoint whose state is worth backing up.
phase_finished – [in] A callback that will be triggered whenever a task phase is finished
task_finished – [in] A callback that will be triggered when the task has finished
- Returns:
an active, running instance of the requested task.
-
Task::ActivePtr restore(const std::function<State()> &get_state, const ConstParametersPtr ¶meters, const Request &request, std::string backup_state, std::function<void(Phase::ConstSnapshotPtr)> update, std::function<void(Task::Active::Backup)> checkpoint, std::function<void(Phase::ConstCompletedPtr)> phase_finished, std::function<void()> task_finished) const
Restore a Task that crashed or disconnected.
- Parameters:
get_state – [in] A callback for retrieving the current state of the robot
parameters – [in] A reference to the parameters for the robot
request – [in] The task request
backup_state – [in] The serialized backup state of the Task
update – [in] A callback that will be triggered when the task has a significant update
checkpoint – [in] A callback that will be triggered when the task has reached a task checkpoint whose state is worth backing up.
phase_finished – [in] A callback that will be triggered whenever a task phase is finished
task_finished – [in] A callback that will be triggered when the task has finished
- Returns:
an active, running instance of the requested task.
-
template<typename Description>