MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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:
34 Asynchronous
35 };
36
39
40 virtual void setupTaskFields(Module* module);
41
57 void setTaskProgressField(FloatField* progressField)
58 {
59 _progress = progressField;
60 }
62 {
63 _status = statusField;
64 }
66
68 {
69 return _startTask;
70 }
72 {
73 return _startTaskSynchronous;
74 }
76 {
77 return _cancelTask;
78 }
80 {
81 return _taskVerboseLogging;
82 }
83
85 {
86 return _taskRunning;
87 }
89 {
90 return _taskFinished;
91 }
93 {
94 return _taskCanceled;
95 }
97 {
98 return _progress;
99 }
101 {
102 return _status;
103 }
104
105
108
112
116 virtual void postTaskFinished();
117
123
126
129 {
130 startTask(Asynchronous);
131 }
138 void startTask(const ExecutionMode mode);
145 {
146 return _restartTask;
147 }
150 {
151 _restartTask = flag;
152 }
153
154private:
156 void preTaskFinished();
157
159 static void taskFinishedCB(void* userData, BackgroundTask* task);
160
161protected:
162 // ----------------------------------------------------------
165 // ----------------------------------------------------------
176
177private:
180 BackgroundTaskHandle _taskHandle;
181
183 Module* _module;
184
186 bool _restartTask;
187
188 friend class Module;
190};
191
192
194
195#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:449
ModuleBackgroundTask extends the ImagingBackgroundTask with several useful methods that allow asynchr...
Base class for an image processing module of the ML.
Definition mlModule.h:150
Field without value for notifications.
Definition mlFields.h:687
Field to encapsulate a string value.
Definition mlFields.h:634
Target mlrange_cast(Source arg)
Generic version of checked ML casts.