MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00004 00010 //---------------------------------------------------------------------------------- 00011 00012 00013 #ifndef __mlBackgroundTaskBaseModule_H 00014 #define __mlBackgroundTaskBaseModule_H 00015 00016 00017 // Local includes 00018 #include "MLBackgroundTasksSystem.h" 00019 00020 // ML includes 00021 #include "mlModuleIncludes.h" 00022 00023 #include "mlModuleBackgroundTask.h" 00024 #include "mlBackgroundTaskManager.h" 00025 00026 ML_START_NAMESPACE 00027 00029 class MLBACKGROUNDTASKS_EXPORT BackgroundTaskBaseModule : public Module 00030 { 00031 public: 00033 enum ExecutionMode { 00034 Synchronous, 00035 Asynchronous 00036 }; 00037 00039 BackgroundTaskBaseModule(); 00040 BackgroundTaskBaseModule(int n, int m); 00041 ~BackgroundTaskBaseModule(); 00042 00044 virtual void handleNotification (Field *field); 00045 00047 virtual void taskFinished(BackgroundTask* task); 00048 00052 virtual void postTaskFinished(); 00053 00058 virtual ModuleBackgroundTask* createTask() = 0; 00059 00061 virtual void updateFinishedTaskStatus(BackgroundTask* task); 00062 00064 void startTask() { startTask(Asynchronous); }; 00065 00072 void startTask(const ExecutionMode mode); 00073 00075 void cancelTask(); 00076 00078 bool hasRunningTask(); 00079 00081 bool willRestartTask() { return _restartTask; } 00082 00084 void setRestartTask(bool flag) { _restartTask = flag; } 00085 00086 private: 00088 void preTaskFinished(); 00089 00091 static void taskFinishedCB(void* userData, BackgroundTask* task); 00092 00094 void init(); 00095 00096 protected: 00097 // ---------------------------------------------------------- 00099 00100 // ---------------------------------------------------------- 00101 00102 NotifyField *_startTask; 00103 00104 NotifyField *_startTaskSynchronous; 00105 00106 NotifyField *_cancelTask; 00107 00108 FloatField *_progress; 00109 00110 StringField *_status; 00111 00112 BoolField *_taskRunning; 00113 00114 NotifyField *_taskFinished; 00115 00116 NotifyField *_taskCanceled; 00117 00118 BoolField *_taskVerboseLogging; 00119 00121 00122 private: 00125 BackgroundTaskHandle _taskHandle; 00126 00128 bool _restartTask; 00129 00131 ML_ABSTRACT_MODULE_CLASS_HEADER(BackgroundTaskBaseModule) 00132 00133 }; 00134 00135 00136 ML_END_NAMESPACE 00137 00138 #endif // __mlBackgroundTaskBaseModule_H 00139 00140