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

Diff of /smsdaemon/Task.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 92 by torben, Mon Jun 16 11:30:20 2008 UTC revision 96 by torben, Mon Jun 16 14:04:19 2008 UTC
# Line 1  Line 1 
1  #ifndef __TASK_H__  #ifndef __TASK_H__
2  #define __TASK_H__  #define __TASK_H__
3    
4    #include <string>
5    
6  class IGsmModem;  class IGsmModem;
7    
8    /* A Task is some piece of code that must be executed regularly, no matter whether
9     * the daemon has received any SMS.
10     *
11     * Tasks exist in two flavours: normal and temporary.
12     *
13     * A normal task is one which lives throughout the execution of the smsdaemon instance.
14     * A pointer to a normal tasks can be retrieved via TaskManager::GetTask(std::string name),
15     * 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     * 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
20     * 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
22     * 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.
24     */
25    
26  class Task  class Task
27  {  {
28  public:  public:
29            Task(std::string name, bool isTemporary);
30    
31            std::string GetName() {return _name;}
32            
33          virtual void ExecuteTask(IGsmModem& modem) = 0;          virtual void ExecuteTask(IGsmModem& modem) = 0;
34    
35            bool IsTemporary() { return _isTemporary; }    
36            bool IsFinished() { return _isFinished; }
37    
38          virtual ~Task() {}          virtual ~Task() {}
39    protected:
40            bool _isFinished;
41    
42    private:
43            std::string _name;
44            bool _isTemporary;
45  };  };
46    
47  #endif // __TASK_H__  #endif // __TASK_H__

Legend:
Removed from v.92  
changed lines
  Added in v.96

  ViewVC Help
Powered by ViewVC 1.1.20