MeVisLab Toolbox Reference
mlBackgroundTaskMethodCallMessage.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_METHOD_CALL_MESSAGE_H
14#define ML_BACKGROUND_TASK_METHOD_CALL_MESSAGE_H
15
16// Local includes
19#include "mlBackgroundTask.h"
20#include <mlArgumentList.h>
21
23
26template<class Object, class Method, class ArgumentList>
28public:
31 _object(object), _method(method), _args(args) {
32 setReceiverHelper(object);
33 }
34
35 void execute() override {
36 if (!sender() || sender()->hasOwner()) {
37 MLCallMethodWithArguments(_object, _method, _args);
38 }
39 }
40
41private:
42 // only set receiver if object has the correct type
43 void setReceiverHelper(BackgroundTaskMessageReceiver* receiverArg) {
44 setReceiver(receiverArg);
45 }
46
47 void setReceiverHelper(void*) {};
48
49 Object* _object;
50 Method _method;
51 ArgumentList _args;
52};
53
55template<class Object, class Method>
59
61template<class Object, class Method, class Arg1>
65
67template<class Object, class Method, class Arg1, class Arg2>
71
73template<class Object, class Method, class Arg1, class Arg2, class Arg3>
77
79template<class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4>
83
85template<class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
89
91
92#endif
93
94
The background task receiver is a light-weight base class which can be inherited (e....
The base class of all background messages.
a generic message that allows to call the member function method on a given object,...
BackgroundTaskMethodCallMessage(Object *object, Method method, const ArgumentList &args)
void execute() override
execute message when it is delivered (reimplement in subclasses)
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
ArgumentList0 MLGenerateArgumentList()
Creates argument list with 0 arguments.
void MLCallMethodWithArguments(Object *object, Method method, const ArgumentList0 &)
Calls a method on given object with 0 arguments.
BackgroundTaskMessage * NewBackgroundTaskMethodCall(Object *object, Method method)
create new method call with 0 arguments