TaskAdapter Class
template <typename Task> class Tasking::TaskAdapterA class template for implementing custom task adapters. More...
Header: | #include <solutions/tasking/tasktree.h> |
Inherits: | Tasking::TaskInterface |
Protected Types
Protected Functions
TaskAdapter() | |
Task * | task() |
const Task * | task() const |
Detailed Description
\inmodule
TaskingSolution
The TaskAdapter class template is responsible for creating a task of the Task
type, starting it, and reporting success or an error when the task is finished. It also associates the adapter with a given Task
type.
Reimplement this class with the actual Task
type to adapt the task's interface into the general TaskTree's interface for managing the Task
instances.
Each subclass needs to provide a public default constructor, implement the start() method, and emit the done() signal when the task is finished. Use task() to access the associated Task
instance.
To use your task adapter inside the task tree, create an alias to the Tasking::CustomTask template passing your task adapter as a template parameter:
// Defines actual worker class Worker {...}; // Adapts Worker's interface to work with task tree class WorkerTaskAdapter : public TaskAdapter<Worker> {...}; // Defines WorkerTask as a new task tree element using WorkerTask = CustomTask<WorkerTaskAdapter>;
For more information on implementing the custom task adapters, refer to Task Adapters.
See also start(), done(), and task().
Member Type Documentation
[alias]
TaskAdapter::Type
Type alias for the Task
type.
Member Function Documentation
[protected]
TaskAdapter::TaskAdapter()
Creates a task adapter for the given Task
type. Internally, it creates an instance of Task
, which is accessible via the task() method.
See also task().
[protected]
Task *TaskAdapter::task()
Returns the pointer to the associated Task
instance.
[protected]
const Task *TaskAdapter::task() const
This is an overloaded function.
Returns the const pointer to the associated Task
instance.