MeVisLabToolboxReference
ml::BackgroundTaskBaseModule Class Reference

baseclass for ML modules that use background tasks More...

#include <mlBackgroundTaskBaseModule.h>

Inheritance diagram for ml::BackgroundTaskBaseModule:
ml::Module ml::FieldContainer ml::Base

List of all members.

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 ModuleBackgroundTaskcreateTask ()=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

Detailed Description

baseclass for ML modules that use background tasks

Definition at line 29 of file mlBackgroundTaskBaseModule.h.


Member Enumeration Documentation

Execution mode of background tasks.

Enumerator:
Synchronous 

Execute the background task synchronously.

Asynchronous 

Execute the background task asynchronousely.

Definition at line 33 of file mlBackgroundTaskBaseModule.h.


Constructor & Destructor Documentation

ml::BackgroundTaskBaseModule::BackgroundTaskBaseModule ( )

Constructor.

ml::BackgroundTaskBaseModule::BackgroundTaskBaseModule ( int  n,
int  m 
)
ml::BackgroundTaskBaseModule::~BackgroundTaskBaseModule ( )

Member Function Documentation

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.


Member Data Documentation


The documentation for this class was generated from the following file: