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
24ML_START_NAMESPACE
25
26class BackgroundTaskBaseModule;
27
29{
30public:
31
37
40
41 virtual void setupTaskFields(Module* module);
42
46 void setTaskRunningField(BoolField* taskRunningField) { _taskRunning = taskRunningField; }
47 void setTaskFinishedField(NotifyField* taskFinishedField) { _taskFinished = taskFinishedField; }
48 void setTaskCanceledField(NotifyField* taskCanceledField) { _taskCanceled = taskCanceledField; }
49 void setTaskProgressField(FloatField* progressField) { _progress = progressField; }
50 void setTaskStatusField(StringField* statusField) { _status = statusField; }
52
57
63
64
66 virtual void handleTaskFieldNotification(Field *field);
67
70 virtual void taskFinished(BackgroundTask* task);
71
75 virtual void postTaskFinished();
76
82
85
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
143ML_END_NAMESPACE
144
145#endif // __mlBackgroundTaskBaseComponent_H
#define MLBACKGROUNDTASKS_EXPORT
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)
void setRestartTask(bool flag)
Sets whether the task should be restarted after the previous task finishes.
ExecutionMode
Execution mode of background tasks.
@ Synchronous
Execute the background task synchronously.
@ Asynchronous
Execute the background task asynchronously.
void startTask(const ExecutionMode mode)
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
void setTaskRunningField(BoolField *taskRunningField)
void setTaskFinishedField(NotifyField *taskFinishedField)
void setTaskStatusField(StringField *statusField)