MeVisLab Toolbox Reference
mlBackgroundTaskModuleHandler.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_BACKGROUND_TASK_MODULE_HANDLER_H
14#define ML_BACKGROUND_TASK_MODULE_HANDLER_H
15
16// Local includes
20
21// ML includes
22#include <mlModuleIncludes.h>
23
25
26class BackgroundTaskBaseModule;
27
29{
30public:
31
35 Asynchronous
36 };
37
40
41 virtual void setupTaskFields(Module* module);
42
49 void setTaskProgressField(FloatField* progressField) { _progress = progressField; }
52
53 NotifyField* getStartTaskField() { return _startTask; }
54 NotifyField* getStartTaskSynchronousField() { return _startTaskSynchronous; }
55 NotifyField* getCancelTaskField() { return _cancelTask; }
56 BoolField* getTaskVerboseLoggingField() { return _taskVerboseLogging; }
57
58 BoolField* getTaskRunningField() { return _taskRunning; }
59 NotifyField* getTaskFinishedField() { return _taskFinished; }
60 NotifyField* getTaskCanceledField() { return _taskCanceled; }
61 FloatField* getTaskProgressField() { return _progress; }
62 StringField* getTaskStatusField() { return _status; }
63
64
67
71
75 virtual void postTaskFinished();
76
82
85
87 void startTask() { startTask(Asynchronous); }
94 void startTask(const ExecutionMode mode);
96 void cancelTask();
100 bool willRestartTask() { return _restartTask; }
102 void setRestartTask(bool flag) { _restartTask = flag; }
103
104private:
106 void preTaskFinished();
107
109 static void taskFinishedCB(void* userData, BackgroundTask* task);
110
111protected:
112 // ----------------------------------------------------------
115 // ----------------------------------------------------------
126
127private:
130 BackgroundTaskHandle _taskHandle;
131
133 Module* _module;
134
136 bool _restartTask;
137
138 friend class Module;
140};
141
142
144
145#endif // __mlBackgroundTaskBaseComponent_H
#define MLBACKGROUNDTASKS_EXPORT
Base class for ML modules that use background tasks.
A handle to a task that has been created by the background task manager.
void setTaskCanceledField(NotifyField *taskCanceledField)
void startTask()
Starts a task with mode Asynchronous.
virtual void handleTaskFieldNotification(Field *field)
Handles field changes of the field field.
void cancelTask()
Cancels a task if it is currently running.
void setTaskProgressField(FloatField *progressField)
bool willRestartTask()
Returns whether the task will be restarted after the previous task has been canceled.
virtual void taskFinished(BackgroundTask *task)
Callback for finished or canceled tasks.
void setRestartTask(bool flag)
Sets whether the task should be restarted after the previous task finishes.
virtual void postTaskFinished()
Called after taskFinished() has been called and can be used to handle the restarting of a task.
ExecutionMode
Execution mode of background tasks.
@ Synchronous
Execute the background task synchronously.
void startTask(const ExecutionMode mode)
Starts a task with user specifying the mode (Synchronous or Asynchronous).
bool hasRunningTask()
Returns whether a task is currently running and is not yet canceled.
virtual void setupTaskFields(Module *module)
virtual void updateFinishedTaskStatus(BackgroundTask *task)
Updates the status and progress field of a finished task. This is called by taskFinished and may be r...
virtual ModuleBackgroundTask * createTask()=0
Requests to create a new task.
void setTaskRunningField(BoolField *taskRunningField)
void setTaskFinishedField(NotifyField *taskFinishedField)
void setTaskStatusField(StringField *statusField)
Base class for a task that is started in an extra thread.
Field to encapsulate a boolean value.
Definition mlFields.h:56
Base class for all fields used in the ML.
Definition mlField.h:73
Field to encapsulate a float value.
Definition mlFields.h:389
ModuleBackgroundTask extends the ImagingBackgroundTask with several useful methods that allow asynchr...
Base class for an image processing module of the ML.
Definition mlModule.h:151
Field without value for notifications.
Definition mlFields.h:598
Field to encapsulate a string value.
Definition mlFields.h:553
Target mlrange_cast(Source arg)
Generic version of checked ML casts.