Inherits from: Task
The Algorithm
class is a core component of the task library that provides a framework for
implementing executable algorithms with standardized signaling, progress reporting, and execution
control. It extends the base Task
class to add algorithm-specific functionality including
execution state tracking, cancellation support, and dirty state management.
ArgumentPack
Algorithm emits the following signals:
Signal | Type | Description | Arguments |
---|---|---|---|
progress data | Data | Reports execution progress | float (0.0 to 1.0) |
started simple | Simple | Indicates algorithm has started execution | None |
finished simple | Simple | Indicates algorithm has completed execution | None |
error data | Data | Reports execution errors | std::string (error message) |
The Algorithm class maintains a "dirty" state that indicates whether the algorithm needs to be re-executed:
isDirty()
: Returns true if the algorithm's input has changed since last executionsetDirty(bool)
: Explicitly sets the dirty stateThis mechanism is useful for:
The run()
method provides asynchronous execution using C++ futures:
This allows algorithms to run in the background without blocking the main thread.
Algorithms can be cancelled during execution:
stop()
to set the stop flagstopRequested()
An Algorithm goes through the following lifecycle:
run()
or runImpl()
called, emits "started"
signalexec()
implementation runs, may report progressThis lifecycle can be repeated multiple times for the same algorithm instance.
The implementation of runImpl()
automatically handles the proper emission of "started" and
"finished" signals, as well as the management of the m_isRunning
state flag.
Here's a simplified view of the key implementation methods:
stopRequested()
regularly during long-running
operationsreportProgress()
to provide feedback on execution
statusrun()
for asynchronous execution
rather than calling exec()
directlyAlgorithm is extended by several specialized classes in the framework: