MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00009 //---------------------------------------------------------------------------------- 00010 00011 00012 #ifndef __mlTypedBackgroundTaskHandle_H 00013 #define __mlTypedBackgroundTaskHandle_H 00014 00015 00016 // Local includes 00017 #include "MLBackgroundTasksSystem.h" 00018 00019 #include "mlBackgroundTaskHandle.h" 00020 #include "mlBackgroundTaskMethodCallMessage.h" 00021 00022 ML_START_NAMESPACE 00023 00024 //----------------------------------------------------------------------- 00025 00026 class BackgroundTask; 00027 00040 template <typename Task> 00041 class TypedBackgroundTaskHandle : public BackgroundTaskHandle 00042 { 00043 public: 00045 typedef Task TaskType; 00046 00047 TypedBackgroundTaskHandle() { _task = NULL; } 00048 00049 TypedBackgroundTaskHandle(Task* task):BackgroundTaskHandle(task) {}; 00050 00051 TypedBackgroundTaskHandle& operator=(Task* task) { 00052 _task = task; 00053 return *this; 00054 } 00055 00056 //------------------------------------------------------ 00058 00080 //------------------------------------------------------ 00081 00082 template <typename Method> 00083 void callMethodOnTask(Method method) 00084 { 00085 BackgroundTaskManager::self().sendMessageToTask(typedTask(), NewBackgroundTaskMethodCall(typedTask(), method)); 00086 } 00087 00088 template <typename Method, typename Arg1> 00089 void callMethodOnTask(Method method, const Arg1& arg1) 00090 { 00091 BackgroundTaskManager::self().sendMessageToTask(typedTask(), NewBackgroundTaskMethodCall(typedTask(), method, arg1)); 00092 } 00093 00094 template <typename Method, typename Arg1, typename Arg2> 00095 void callMethodOnTask(Method method, const Arg1& arg1, const Arg2& arg2) 00096 { 00097 BackgroundTaskManager::self().sendMessageToTask(typedTask(), NewBackgroundTaskMethodCall(typedTask(), method, arg1, arg2)); 00098 } 00099 00100 template <typename Method, typename Arg1, typename Arg2, typename Arg3> 00101 void callMethodOnTask(Method method, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3) 00102 { 00103 BackgroundTaskManager::self().sendMessageToTask(typedTask(), NewBackgroundTaskMethodCall(typedTask(), method, arg1, arg2, arg3)); 00104 } 00105 00106 template <typename Method, typename Arg1, typename Arg2, typename Arg3, typename Arg4> 00107 void callMethodOnTask(Method method, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) 00108 { 00109 BackgroundTaskManager::self().sendMessageToTask(typedTask(), NewBackgroundTaskMethodCall(typedTask(), method, arg1, arg2, arg3, arg4)); 00110 } 00111 00112 template <typename Method, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> 00113 void callMethodOnTask(Method method, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) 00114 { 00115 BackgroundTaskManager::self().sendMessageToTask(typedTask(), NewBackgroundTaskMethodCall(typedTask(), method, arg1, arg2, arg3, arg4, arg5)); 00116 } 00117 00119 00120 protected: 00122 inline Task* typedTask() const { return static_cast<Task*>(_task); } 00123 }; 00124 00125 ML_END_NAMESPACE 00126 00127 #endif 00128 00129