3 |
|
|
4 |
#include <string> |
#include <string> |
5 |
|
|
6 |
class IGsmModem; |
class ISmsTransceiver; |
7 |
|
|
8 |
/* A Task is some piece of code that must be executed regularly, no matter whether |
/* A Task is some piece of code that must be executed regularly, no matter whether |
9 |
* the daemon has received any SMS. |
* the daemon has received any SMS. |
10 |
* |
* |
11 |
* Tasks exist in two flavours: persistant and temporary. |
* Tasks exist in two flavours: persistant and temporary. |
12 |
* |
* |
13 |
* A persistant task is one which lives throughout the execution of the smsdaemon instance. |
* A persistant task is one which lives throughout the execution of the smsdaemon instance. |
14 |
* A pointer to a persistant task can be retrieved via TaskManager::GetTask(std::string name), |
* A pointer to a persistant task can be retrieved via TaskManager::GetTask(std::string name), |
15 |
* and thus it must have a unique name. |
* and thus it must have a unique name. |
16 |
* |
* |
17 |
* A temporary tasks is of a more short-lived nature. It behaves like a fire-and-forget piece of code. |
* A temporary tasks is of a more short-lived nature. It behaves like a fire-and-forget piece of code. |
18 |
* A temporary task can be created at any time by any piece of code. This creation must be dynamicaly |
* A temporary task can be created at any time by any piece of code. This creation must be dynamicaly |
19 |
* through the new() operator. When created it registers itself with the task manager, and here after any |
* through the new() operator. When created it registers itself with the task manager, and here after any |
20 |
* references to the task must be nulled. |
* references to the task must be nulled. |
21 |
* When the temporary task has done its work it must set the protected variale to true, and the |
* When the temporary task has done its work it must set the protected variale to true, and the |
22 |
* task instance will here after be deleted by the task-manager. |
* task instance will here after be deleted by the task-manager. |
23 |
* Temporary tasks does not need a unique name, and once created you cannot get a pointer to it again. |
* Temporary tasks does not need a unique name, and once created you cannot get a pointer to it again. |
24 |
*/ |
*/ |
25 |
|
|
28 |
public: |
public: |
29 |
Task(std::string name, bool isTemporary); |
Task(std::string name, bool isTemporary); |
30 |
|
|
31 |
std::string GetName() {return _name;} |
std::string GetName() |
32 |
|
{ |
33 |
virtual void ExecuteTask(IGsmModem& modem) = 0; |
return _name; |
34 |
|
} |
35 |
bool IsTemporary() { return _isTemporary; } |
|
36 |
bool IsFinished() { return _isFinished; } |
void RegisterTask(); |
37 |
|
|
38 |
|
virtual void ExecuteTask(ISmsTransceiver& modem) = 0; |
39 |
|
|
40 |
|
bool IsTemporary() |
41 |
|
{ |
42 |
|
return _isTemporary; |
43 |
|
} |
44 |
|
bool IsFinished() |
45 |
|
{ |
46 |
|
return _isFinished; |
47 |
|
} |
48 |
|
|
49 |
virtual ~Task() {} |
virtual ~Task() {} |
50 |
protected: |
protected: |