--- smsdaemon/Task.h 2008/06/16 12:21:30 95 +++ smsdaemon/Task.h 2008/06/16 14:04:19 96 @@ -1,13 +1,47 @@ #ifndef __TASK_H__ #define __TASK_H__ +#include + class IGsmModem; +/* A Task is some piece of code that must be executed regularly, no matter whether + * the daemon has received any SMS. + * + * Tasks exist in two flavours: normal and temporary. + * + * A normal task is one which lives throughout the execution of the smsdaemon instance. + * A pointer to a normal tasks can be retrieved via TaskManager::GetTask(std::string name), + * and thus it must have a unique name. + * + * A temporary tasks is of a more short-lived nature. It behaves like a fire-and-forget piece of code. + * A temporary task can be created at any time by any piece of code. This creation must be dynamicaly + * through the new() operator. When created it registers itself with the task manager, and here after any + * references to the task must be nulled. + * When the temporary task has done its work it must set the protected variale to true, and the + * task instance will here after be deleted by the task-manager. + * Temporary tasks does not need a unique name, and once created you cannot get a pointer to it again. + */ + class Task { public: + Task(std::string name, bool isTemporary); + + std::string GetName() {return _name;} + virtual void ExecuteTask(IGsmModem& modem) = 0; + + bool IsTemporary() { return _isTemporary; } + bool IsFinished() { return _isFinished; } + virtual ~Task() {} +protected: + bool _isFinished; + +private: + std::string _name; + bool _isTemporary; }; #endif // __TASK_H__