MeVisLabToolboxReference
MeVis/Foundation/Sources/MLBackgroundTasks/mlBackgroundTaskMethodCallMessage.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00009 //----------------------------------------------------------------------------------
00010 
00011 
00012 #ifndef __mlBackgroundTaskMethodCallMessage_H
00013 #define __mlBackgroundTaskMethodCallMessage_H
00014 
00015 
00016 // Local includes
00017 #include "MLBackgroundTasksSystem.h"
00018 #include "mlBackgroundTaskMessage.h"
00019 #include "mlBackgroundTask.h"
00020 #include "mlArgumentList.h"
00021 
00022 ML_START_NAMESPACE
00023 
00026 template<class Object, class Method, class ArgumentList>
00027 class BackgroundTaskMethodCallMessage : public BackgroundTaskMessage {
00028 public:
00029   BackgroundTaskMethodCallMessage(Object* object, Method method, const ArgumentList& args):
00030     BackgroundTaskMessage(),
00031     _object(object), _method(method), _args(args) {}
00032   
00033   virtual void execute() {
00034     if (!sender() || sender()->hasOwner()) {
00035       MLCallMethodWithArguments(_object, _method, _args);
00036     }
00037   }
00038 
00039 private:
00040   Object* _object;
00041   Method  _method;
00042   ArgumentList _args;
00043 };
00044 
00046 template<class Object, class Method>
00047 inline BackgroundTaskMessage* NewBackgroundTaskMethodCall(Object* object, Method method) {
00048   return new BackgroundTaskMethodCallMessage<Object, Method, ArgumentList0>(object, method, MLGenerateArgumentList());
00049 }
00050 
00052 template<class Object, class Method, class Arg1>
00053 inline BackgroundTaskMessage* NewBackgroundTaskMethodCall(Object* object, Method method, const Arg1& arg1) {
00054   return new BackgroundTaskMethodCallMessage<Object, Method, ArgumentList1<Arg1> >(object, method, MLGenerateArgumentList(arg1));
00055 }
00056 
00058 template<class Object, class Method, class Arg1, class Arg2>
00059 inline BackgroundTaskMessage* NewBackgroundTaskMethodCall(Object* object, Method method, const Arg1& arg1, const Arg2& arg2) {
00060   return new BackgroundTaskMethodCallMessage<Object, Method, ArgumentList2<Arg1, Arg2> >(object, method, MLGenerateArgumentList(arg1, arg2));
00061 }
00062 
00064 template<class Object, class Method, class Arg1, class Arg2, class Arg3>
00065 inline BackgroundTaskMessage* NewBackgroundTaskMethodCall(Object* object, Method method, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3) {
00066   return new BackgroundTaskMethodCallMessage<Object, Method, ArgumentList3<Arg1, Arg2, Arg3> >(object, method, MLGenerateArgumentList(arg1, arg2, arg3));
00067 }
00068 
00070 template<class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4>
00071 inline BackgroundTaskMessage* NewBackgroundTaskMethodCall(Object* object, Method method, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) {
00072   return new BackgroundTaskMethodCallMessage<Object, Method, ArgumentList4<Arg1, Arg2, Arg3, Arg4> >(object, method, MLGenerateArgumentList(arg1, arg2, arg3, arg4));
00073 }
00074 
00076 template<class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
00077 inline BackgroundTaskMessage* NewBackgroundTaskMethodCall(Object* object, Method method, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) {
00078   return new BackgroundTaskMethodCallMessage<Object, Method, ArgumentList5<Arg1, Arg2, Arg3, Arg4, Arg5> >(object, method, MLGenerateArgumentList(arg1, arg2, arg3, arg4, arg5));
00079 }
00080 
00081 ML_END_NAMESPACE
00082 
00083 #endif
00084 
00085