MeVisLabToolboxReference
|
baseclass for ML modules that use background tasks More...
#include <mlBackgroundTaskBaseModule.h>
Public Types | |
enum | ExecutionMode { Synchronous, Asynchronous } |
Execution mode of background tasks. More... | |
Public Member Functions | |
BackgroundTaskBaseModule () | |
Constructor. | |
BackgroundTaskBaseModule (int n, int m) | |
~BackgroundTaskBaseModule () | |
virtual void | handleNotification (Field *field) |
Handle field changes of the field field . | |
virtual void | taskFinished (BackgroundTask *task) |
Callback for finished/canceled tasks (to be derived, make sure to call parent method. | |
virtual void | postTaskFinished () |
Called after taskFinished() has been called and can be used to handle the restarting of a task. | |
virtual ModuleBackgroundTask * | createTask ()=0 |
Request a new task to be created, reimplement this method and make sure that you keep no reference to your task, because it will be handed to the BackgroundTaskManager the ownership of the pointer is passed to the caller. | |
virtual void | updateFinishedTaskStatus (BackgroundTask *task) |
Updates the status and progress field of a finished task, is called by taskFinished and may be reimplemented. | |
void | startTask () |
Start a task with mode Asynchronous. | |
void | startTask (const ExecutionMode mode) |
Start a task with user specifying the mode (Synchronous or Asynchronous). | |
void | cancelTask () |
Cancel a task if it is currently running. | |
bool | hasRunningTask () |
Returns if a task is currently running (and not yet canceled). | |
bool | willRestartTask () |
Returns if the task will be restarted after the previous task has been canceled. | |
void | setRestartTask (bool flag) |
Set if the task should be restarted after the previous task finishes. | |
Protected Attributes | |
Module field declarations | |
NotifyField * | _startTask |
NotifyField * | _startTaskSynchronous |
NotifyField * | _cancelTask |
FloatField * | _progress |
StringField * | _status |
BoolField * | _taskRunning |
NotifyField * | _taskFinished |
NotifyField * | _taskCanceled |
BoolField * | _taskVerboseLogging |
baseclass for ML modules that use background tasks
Definition at line 29 of file mlBackgroundTaskBaseModule.h.
Execution mode of background tasks.
Synchronous |
Execute the background task synchronously. |
Asynchronous |
Execute the background task asynchronousely. |
Definition at line 33 of file mlBackgroundTaskBaseModule.h.
ml::BackgroundTaskBaseModule::BackgroundTaskBaseModule | ( | ) |
Constructor.
ml::BackgroundTaskBaseModule::BackgroundTaskBaseModule | ( | int | n, |
int | m | ||
) |
ml::BackgroundTaskBaseModule::~BackgroundTaskBaseModule | ( | ) |
void ml::BackgroundTaskBaseModule::cancelTask | ( | ) |
Cancel a task if it is currently running.
virtual ModuleBackgroundTask* ml::BackgroundTaskBaseModule::createTask | ( | ) | [pure virtual] |
Request a new task to be created, reimplement this method and make sure that you keep no reference to your task, because it will be handed to the BackgroundTaskManager the ownership of the pointer is passed to the caller.
Note: only return a new task if all preconditions are met!!!
virtual void ml::BackgroundTaskBaseModule::handleNotification | ( | Field * | field | ) | [virtual] |
Handle field changes of the field field
.
Reimplemented from ml::Module.
bool ml::BackgroundTaskBaseModule::hasRunningTask | ( | ) |
Returns if a task is currently running (and not yet canceled).
virtual void ml::BackgroundTaskBaseModule::postTaskFinished | ( | ) | [virtual] |
Called after taskFinished() has been called and can be used to handle the restarting of a task.
NOTE: The previous task will already be deleted when this method is called.
void ml::BackgroundTaskBaseModule::setRestartTask | ( | bool | flag | ) | [inline] |
Set if the task should be restarted after the previous task finishes.
Definition at line 84 of file mlBackgroundTaskBaseModule.h.
void ml::BackgroundTaskBaseModule::startTask | ( | const ExecutionMode | mode | ) |
Start a task with user specifying the mode (Synchronous or Asynchronous).
If a task is already running, it is canceled and a new task is started after it has finished. This will not happen within startTask, it will happen at a later time. You can check if a restart was scheduled by using willRestartTask().
void ml::BackgroundTaskBaseModule::startTask | ( | ) | [inline] |
Start a task with mode Asynchronous.
Definition at line 64 of file mlBackgroundTaskBaseModule.h.
References startTask().
Referenced by startTask().
virtual void ml::BackgroundTaskBaseModule::taskFinished | ( | BackgroundTask * | task | ) | [virtual] |
Callback for finished/canceled tasks (to be derived, make sure to call parent method.
virtual void ml::BackgroundTaskBaseModule::updateFinishedTaskStatus | ( | BackgroundTask * | task | ) | [virtual] |
Updates the status and progress field of a finished task, is called by taskFinished and may be reimplemented.
bool ml::BackgroundTaskBaseModule::willRestartTask | ( | ) | [inline] |
Returns if the task will be restarted after the previous task has been canceled.
Definition at line 81 of file mlBackgroundTaskBaseModule.h.
NotifyField* ml::BackgroundTaskBaseModule::_cancelTask [protected] |
Definition at line 106 of file mlBackgroundTaskBaseModule.h.
FloatField* ml::BackgroundTaskBaseModule::_progress [protected] |
Definition at line 108 of file mlBackgroundTaskBaseModule.h.
NotifyField* ml::BackgroundTaskBaseModule::_startTask [protected] |
Definition at line 102 of file mlBackgroundTaskBaseModule.h.
Definition at line 104 of file mlBackgroundTaskBaseModule.h.
StringField* ml::BackgroundTaskBaseModule::_status [protected] |
Definition at line 110 of file mlBackgroundTaskBaseModule.h.
NotifyField* ml::BackgroundTaskBaseModule::_taskCanceled [protected] |
Definition at line 116 of file mlBackgroundTaskBaseModule.h.
NotifyField* ml::BackgroundTaskBaseModule::_taskFinished [protected] |
Definition at line 114 of file mlBackgroundTaskBaseModule.h.
BoolField* ml::BackgroundTaskBaseModule::_taskRunning [protected] |
Definition at line 112 of file mlBackgroundTaskBaseModule.h.
Definition at line 118 of file mlBackgroundTaskBaseModule.h.