/[projects]/smsdaemon/Task.h
ViewVC logotype

Annotation of /smsdaemon/Task.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 196 - (hide annotations) (download)
Thu Dec 18 06:53:29 2008 UTC (15 years, 5 months ago) by torben
File MIME type: text/plain
File size: 1506 byte(s)
Make pretty

astyle -t -b -N

1 torben 26 #ifndef __TASK_H__
2     #define __TASK_H__
3    
4 torben 96 #include <string>
5    
6 torben 149 class ISmsTransceiver;
7 torben 26
8 torben 96 /* A Task is some piece of code that must be executed regularly, no matter whether
9     * the daemon has received any SMS.
10 torben 196 *
11 torben 129 * Tasks exist in two flavours: persistant and temporary.
12 torben 96 *
13 torben 129 * A persistant task is one which lives throughout the execution of the smsdaemon instance.
14 torben 196 * A pointer to a persistant task can be retrieved via TaskManager::GetTask(std::string name),
15 torben 96 * 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.
18 torben 196 * A temporary task can be created at any time by any piece of code. This creation must be dynamicaly
19 torben 96 * 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.
21 torben 196 * 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.
23 torben 96 * Temporary tasks does not need a unique name, and once created you cannot get a pointer to it again.
24     */
25    
26 torben 26 class Task
27     {
28     public:
29 torben 96 Task(std::string name, bool isTemporary);
30    
31 torben 196 std::string GetName()
32     {
33     return _name;
34     }
35    
36 torben 149 virtual void ExecuteTask(ISmsTransceiver& modem) = 0;
37 torben 96
38 torben 196 bool IsTemporary()
39     {
40     return _isTemporary;
41     }
42     bool IsFinished()
43     {
44     return _isFinished;
45     }
46 torben 96
47 torben 26 virtual ~Task() {}
48 torben 96 protected:
49     bool _isFinished;
50    
51     private:
52     std::string _name;
53     bool _isTemporary;
54 torben 26 };
55    
56     #endif // __TASK_H__

  ViewVC Help
Powered by ViewVC 1.1.20