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 
57  virtual void execute() = 0;
58 
61  virtual void executeSynchronous() { execute(); }
62 
66  virtual bool finishedProcessing() { return true; }
67 
69  virtual void taskWillBeDestroyed();
70 
71 private:
72  BackgroundTask* _sender;
74 };
75 
76 //-----------------------------------------------------------------------
77 
78 ML_END_NAMESPACE
79 
80 #endif
81 
82 
#define MLBACKGROUNDTASKS_EXPORT
Project global and OS specific declarations.
The background task receiver is a light-weight base class which can be inherited (e....
The base class of all background messages.
BackgroundTask * sender()
returns the task from which the message originates
virtual void executeSynchronous()
execute message when it is delivered and the task runs synchronous, the default implementation just c...
void setSender(BackgroundTask *task)
set who sends the message (default is NULL and means that the message's sender is not a BackgroundTas...
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)
set who receives the message (default is NULL)
virtual void execute()=0
execute message when it is delivered (reimplement in subclasses)
virtual bool finishedProcessing()
tells if the message needs further processing or if it may be deleted if true is returned,...
Base class for a task that is started in an extra thread.