MeVisLab Toolbox Reference
ml::BackgroundTaskModuleHandler Class Referenceabstract

#include <mlBackgroundTaskModuleHandler.h>

Inheritance diagram for ml::BackgroundTaskModuleHandler:
ml::BackgroundTaskBaseModule

Public Types

enum  ExecutionMode { Synchronous , Asynchronous }
 Execution mode of background tasks. More...
 

Public Member Functions

 BackgroundTaskModuleHandler ()
 
virtual ~BackgroundTaskModuleHandler ()
 
virtual void setupTaskFields (Module *module)
 
NotifyFieldgetStartTaskField ()
 
NotifyFieldgetStartTaskSynchronousField ()
 
NotifyFieldgetCancelTaskField ()
 
BoolFieldgetTaskVerboseLoggingField ()
 
BoolFieldgetTaskRunningField ()
 
NotifyFieldgetTaskFinishedField ()
 
NotifyFieldgetTaskCanceledField ()
 
FloatFieldgetTaskProgressField ()
 
StringFieldgetTaskStatusField ()
 
virtual void handleTaskFieldNotification (Field *field)
 Handles field changes of the field field. More...
 
virtual void taskFinished (BackgroundTask *task)
 Callback for finished or canceled tasks. More...
 
virtual void postTaskFinished ()
 Called after taskFinished() has been called and can be used to handle the restarting of a task. More...
 
virtual ModuleBackgroundTaskcreateTask ()=0
 Requests to create a new task. More...
 
virtual void updateFinishedTaskStatus (BackgroundTask *task)
 Updates the status and progress field of a finished task. This is called by taskFinished and may be reimplemented. More...
 
void startTask ()
 Starts a task with mode Asynchronous. More...
 
void startTask (const ExecutionMode mode)
 Starts a task with user specifying the mode (Synchronous or Asynchronous). More...
 
void cancelTask ()
 Cancels a task if it is currently running. More...
 
bool hasRunningTask ()
 Returns whether a task is currently running and is not yet canceled. More...
 
bool willRestartTask ()
 Returns whether the task will be restarted after the previous task has been canceled. More...
 
void setRestartTask (bool flag)
 Sets whether the task should be restarted after the previous task finishes. More...
 
void setTaskRunningField (BoolField *taskRunningField)
 
void setTaskFinishedField (NotifyField *taskFinishedField)
 
void setTaskCanceledField (NotifyField *taskCanceledField)
 
void setTaskProgressField (FloatField *progressField)
 
void setTaskStatusField (StringField *statusField)
 

Protected Attributes

Module field declarations
NotifyField_startTask
 
NotifyField_startTaskSynchronous
 
NotifyField_cancelTask
 
FloatField_progress
 
StringField_status
 
BoolField_taskRunning
 
NotifyField_taskFinished
 
NotifyField_taskCanceled
 
BoolField_taskVerboseLogging
 

Friends

class Module
 
class BackgroundTaskBaseModule
 

Detailed Description

Definition at line 28 of file mlBackgroundTaskModuleHandler.h.

Member Enumeration Documentation

◆ ExecutionMode

Execution mode of background tasks.

Enumerator
Synchronous 

Execute the background task synchronously.

Asynchronous 

Execute the background task asynchronously.

Definition at line 33 of file mlBackgroundTaskModuleHandler.h.

Constructor & Destructor Documentation

◆ BackgroundTaskModuleHandler()

ml::BackgroundTaskModuleHandler::BackgroundTaskModuleHandler ( )

◆ ~BackgroundTaskModuleHandler()

virtual ml::BackgroundTaskModuleHandler::~BackgroundTaskModuleHandler ( )
virtual

Member Function Documentation

◆ cancelTask()

void ml::BackgroundTaskModuleHandler::cancelTask ( )

Cancels a task if it is currently running.

◆ createTask()

virtual ModuleBackgroundTask* ml::BackgroundTaskModuleHandler::createTask ( )
pure virtual

Requests to create a new task.

Reimplement this method and make sure that you keep no reference to your task, as 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!

◆ getCancelTaskField()

NotifyField* ml::BackgroundTaskModuleHandler::getCancelTaskField ( )
inline

Definition at line 55 of file mlBackgroundTaskModuleHandler.h.

◆ getStartTaskField()

NotifyField* ml::BackgroundTaskModuleHandler::getStartTaskField ( )
inline

Definition at line 53 of file mlBackgroundTaskModuleHandler.h.

◆ getStartTaskSynchronousField()

NotifyField* ml::BackgroundTaskModuleHandler::getStartTaskSynchronousField ( )
inline

Definition at line 54 of file mlBackgroundTaskModuleHandler.h.

◆ getTaskCanceledField()

NotifyField* ml::BackgroundTaskModuleHandler::getTaskCanceledField ( )
inline

Definition at line 60 of file mlBackgroundTaskModuleHandler.h.

◆ getTaskFinishedField()

NotifyField* ml::BackgroundTaskModuleHandler::getTaskFinishedField ( )
inline

Definition at line 59 of file mlBackgroundTaskModuleHandler.h.

◆ getTaskProgressField()

FloatField* ml::BackgroundTaskModuleHandler::getTaskProgressField ( )
inline

Definition at line 61 of file mlBackgroundTaskModuleHandler.h.

◆ getTaskRunningField()

BoolField* ml::BackgroundTaskModuleHandler::getTaskRunningField ( )
inline

Definition at line 58 of file mlBackgroundTaskModuleHandler.h.

◆ getTaskStatusField()

StringField* ml::BackgroundTaskModuleHandler::getTaskStatusField ( )
inline

Definition at line 62 of file mlBackgroundTaskModuleHandler.h.

◆ getTaskVerboseLoggingField()

BoolField* ml::BackgroundTaskModuleHandler::getTaskVerboseLoggingField ( )
inline

Definition at line 56 of file mlBackgroundTaskModuleHandler.h.

◆ handleTaskFieldNotification()

virtual void ml::BackgroundTaskModuleHandler::handleTaskFieldNotification ( Field field)
virtual

Handles field changes of the field field.

◆ hasRunningTask()

bool ml::BackgroundTaskModuleHandler::hasRunningTask ( )

Returns whether a task is currently running and is not yet canceled.

◆ postTaskFinished()

virtual void ml::BackgroundTaskModuleHandler::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.

◆ setRestartTask()

void ml::BackgroundTaskModuleHandler::setRestartTask ( bool  flag)
inline

Sets whether the task should be restarted after the previous task finishes.

Definition at line 102 of file mlBackgroundTaskModuleHandler.h.

◆ setTaskCanceledField()

void ml::BackgroundTaskModuleHandler::setTaskCanceledField ( NotifyField taskCanceledField)
inline

Definition at line 48 of file mlBackgroundTaskModuleHandler.h.

◆ setTaskFinishedField()

void ml::BackgroundTaskModuleHandler::setTaskFinishedField ( NotifyField taskFinishedField)
inline

Definition at line 47 of file mlBackgroundTaskModuleHandler.h.

◆ setTaskProgressField()

void ml::BackgroundTaskModuleHandler::setTaskProgressField ( FloatField progressField)
inline

Definition at line 49 of file mlBackgroundTaskModuleHandler.h.

◆ setTaskRunningField()

void ml::BackgroundTaskModuleHandler::setTaskRunningField ( BoolField taskRunningField)
inline

Optionally set output fields from outside before calling setupTaskFields. We do not allow to set fields that trigger or cancel a process, as that could easily lead to double notifications when old code already handles those fields.

Definition at line 46 of file mlBackgroundTaskModuleHandler.h.

◆ setTaskStatusField()

void ml::BackgroundTaskModuleHandler::setTaskStatusField ( StringField statusField)
inline

Definition at line 50 of file mlBackgroundTaskModuleHandler.h.

◆ setupTaskFields()

virtual void ml::BackgroundTaskModuleHandler::setupTaskFields ( Module module)
virtual

◆ startTask() [1/2]

void ml::BackgroundTaskModuleHandler::startTask ( )
inline

Starts a task with mode Asynchronous.

Definition at line 87 of file mlBackgroundTaskModuleHandler.h.

References startTask().

Referenced by startTask().

◆ startTask() [2/2]

void ml::BackgroundTaskModuleHandler::startTask ( const ExecutionMode  mode)

Starts 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 whether a restart was scheduled by using willRestartTask().

◆ taskFinished()

virtual void ml::BackgroundTaskModuleHandler::taskFinished ( BackgroundTask task)
virtual

Callback for finished or canceled tasks.

If overriding this, make sure to call the parent method.

◆ updateFinishedTaskStatus()

virtual void ml::BackgroundTaskModuleHandler::updateFinishedTaskStatus ( BackgroundTask task)
virtual

Updates the status and progress field of a finished task. This is called by taskFinished and may be reimplemented.

◆ willRestartTask()

bool ml::BackgroundTaskModuleHandler::willRestartTask ( )
inline

Returns whether the task will be restarted after the previous task has been canceled.

Definition at line 100 of file mlBackgroundTaskModuleHandler.h.

Friends And Related Function Documentation

◆ BackgroundTaskBaseModule

friend class BackgroundTaskBaseModule
friend

Definition at line 139 of file mlBackgroundTaskModuleHandler.h.

◆ Module

friend class Module
friend

Definition at line 138 of file mlBackgroundTaskModuleHandler.h.

Member Data Documentation

◆ _cancelTask

NotifyField* ml::BackgroundTaskModuleHandler::_cancelTask
protected

Definition at line 118 of file mlBackgroundTaskModuleHandler.h.

◆ _progress

FloatField* ml::BackgroundTaskModuleHandler::_progress
protected

Definition at line 119 of file mlBackgroundTaskModuleHandler.h.

◆ _startTask

NotifyField* ml::BackgroundTaskModuleHandler::_startTask
protected

Definition at line 116 of file mlBackgroundTaskModuleHandler.h.

◆ _startTaskSynchronous

NotifyField* ml::BackgroundTaskModuleHandler::_startTaskSynchronous
protected

Definition at line 117 of file mlBackgroundTaskModuleHandler.h.

◆ _status

StringField* ml::BackgroundTaskModuleHandler::_status
protected

Definition at line 120 of file mlBackgroundTaskModuleHandler.h.

◆ _taskCanceled

NotifyField* ml::BackgroundTaskModuleHandler::_taskCanceled
protected

Definition at line 123 of file mlBackgroundTaskModuleHandler.h.

◆ _taskFinished

NotifyField* ml::BackgroundTaskModuleHandler::_taskFinished
protected

Definition at line 122 of file mlBackgroundTaskModuleHandler.h.

◆ _taskRunning

BoolField* ml::BackgroundTaskModuleHandler::_taskRunning
protected

Definition at line 121 of file mlBackgroundTaskModuleHandler.h.

◆ _taskVerboseLogging

BoolField* ml::BackgroundTaskModuleHandler::_taskVerboseLogging
protected

Definition at line 124 of file mlBackgroundTaskModuleHandler.h.


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