MeVisLab Toolbox Reference
mlBackgroundTaskMessage.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_MESSAGE_H
14 #define ML_BACKGROUND_TASK_MESSAGE_H
15 
16 // Local includes
18 
19 ML_START_NAMESPACE
20 
21 //-----------------------------------------------------------------------
22 class BackgroundTask;
23 
32 public:
35 };
36 
37 //-----------------------------------------------------------------------
40 public:
43 
45  void setSender(BackgroundTask* task) { _sender = task; }
46 
48  BackgroundTask* sender() { return _sender; }
49 
51  void setReceiver(BackgroundTaskMessageReceiver* receiverArg) { _receiver = receiverArg; }
52 
54  BackgroundTaskMessageReceiver* receiver() { return _receiver; }
55 
58  virtual void execute() = 0;
59 
63  virtual void executeSynchronous() { execute(); }
64 
68  virtual bool finishedProcessing() { return true; }
69 
71  virtual void taskWillBeDestroyed();
72 
73 private:
74  BackgroundTask* _sender;
76 };
77 
78 //-----------------------------------------------------------------------
79 
80 ML_END_NAMESPACE
81 
82 #endif
83 
84 
#define MLBACKGROUNDTASKS_EXPORT
The background task receiver is a light-weight base class that can be inherited (e....
The base class of all background messages.
BackgroundTask * sender()
Returns the task from which the message originates.
virtual void executeSynchronous()
Executes message when it is delivered and the task runs synchronously.
void setSender(BackgroundTask *task)
Sets who sends the message. Default is NULL and this means that the message's sender is not a Backgro...
virtual void taskWillBeDestroyed()
This needs to be implemented if the message uses finishedProcessing() and the task is finished while ...
BackgroundTaskMessageReceiver * receiver()
Returns the object which receives the message. Default is NULL.
void setReceiver(BackgroundTaskMessageReceiver *receiverArg)
Sets who receives the message. Default is NULL.
virtual void execute()=0
Executes message when it is delivered.
virtual bool finishedProcessing()
Returns whether the message needs further processing or if it may be deleted.
Base class for a task that is started in an extra thread.