MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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> class BackgroundTaskMethodCallMessage
28{
29public:
32 , _object(object)
33 , _method(method)
34 , _args(args)
35 {
36 setReceiverHelper(object);
37 }
38
39 void execute() override
40 {
41 if (!sender() || sender()->hasOwner()) {
42 MLCallMethodWithArguments(_object, _method, _args);
43 }
44 }
45
46private:
47 // Only set the receiver if the object has the correct type.
48 void setReceiverHelper(BackgroundTaskMessageReceiver* receiverArg)
49 {
50 setReceiver(receiverArg);
51 }
52
53 void setReceiverHelper(void*) {};
54
55 Object* _object;
56 Method _method;
57 ArgumentList _args;
58};
59
61template <class Object, class Method>
66
68template <class Object, class Method, class Arg1>
74
76template <class Object, class Method, class Arg1, class Arg2>
83
85template <class Object, class Method, class Arg1, class Arg2, class Arg3>
92
94template <class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4>
101
103template <class Object, class Method, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
111
113
114#endif
The background task receiver is a light-weight base class that 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
Executes message when it is delivered.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
ArgumentList0 MLGenerateArgumentList()
Creates argument list with zero arguments.
void MLCallMethodWithArguments(Object *object, Method method, const ArgumentList0 &)
Calls a method on given object with zero arguments.
BackgroundTaskMessage * NewBackgroundTaskMethodCall(Object *object, Method method)
Creates a new method call with zero arguments.