MeVisLabToolboxReference
MeVis/Foundation/Sources/MLBackgroundTasks/mlBackgroundTaskHandle.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00009 //----------------------------------------------------------------------------------
00010 
00011 
00012 #ifndef __mlBackgroundTaskHandle_H
00013 #define __mlBackgroundTaskHandle_H
00014 
00015 
00016 // Local includes
00017 #include "MLBackgroundTasksSystem.h"
00018 
00019 ML_START_NAMESPACE
00020 
00021 //-----------------------------------------------------------------------
00022 
00023 class BackgroundTask;
00024 
00026 
00030 class MLBACKGROUNDTASKS_EXPORT BackgroundTaskHandle
00031 {
00032 public:
00033   BackgroundTaskHandle() { _task = NULL; }
00034 
00036   void clear();
00037 
00039   bool hasTask();
00040 
00042   bool hasRunningTask();
00043 
00045   bool isCanceled();
00046 
00048   void cancel();
00049 
00051   void setOwnerWasDeleted();
00052 
00053 protected:
00054   friend class BackgroundTaskManager;
00055   friend class BackgroundTaskHandleAccessor;
00056   BackgroundTaskHandle(BackgroundTask* task) { _task = task; }
00057 
00058   BackgroundTask* _task;
00059 };
00060 
00064 class BackgroundTaskHandleAccessor
00065 {
00066 public:
00067   inline static BackgroundTask* get(const BackgroundTaskHandle& handle) { return handle._task; }
00068 };
00069 
00070 ML_END_NAMESPACE
00071 
00072 #endif
00073 
00074