scheduler::Task Class Reference

Base task class. More...

#include <scheduler.h>

Inheritance diagram for scheduler::Task:

scheduler::TaskAlways scheduler::TaskStep scheduler::TaskTimeout

List of all members.

Public Types

enum  { rOK = 0x0, rSlept = 0x1, rRemove = 0x2, rFree = (rRemove | 0x4) }
 Possible return value bits for run(). More...

Public Member Functions

 Task (modules::Module *module, std::string const &name="", std::string const &desc="")
 Constructor.
 Task (Task const &t)
 Copy constructor.
Taskoperator= (Task const &right)
 Assignment operator.
virtual ~Task ()
 Destructor.
virtual bool poll ()=0
 Determines whether the task should be run.
virtual int run ()=0
 Runs the task.
modules::Modulemodule () const
 Returns the module this task belongs to.
virtual std::string description () const
 Returns the description of the task.
virtual std::string name () const
 Returns the name of the task.

Protected Attributes

modules::Modulem_module
 The module this task belongs to.
std::string m_name
 The task name.
std::string m_desc
 The task description.


Detailed Description

The Task class implements a task used by the Scheduler class. Each Task object has its own task type, allowing you to remove all tasks of a specific type easily through the Scheduler object.

This class must not be used directly; instead, you must inherit it and override the abstract functions.


Member Enumeration Documentation

anonymous enum

Enumerator:
rOK  Use this as an alias for 0.
rSlept  The task has called sleep() -- no need to call it again.
rRemove  Remove the task from the list.
rFree  Remove the task from the list and call operator delete on it.


Constructor & Destructor Documentation

scheduler::Task::Task ( modules::Module module,
std::string const &  name = "",
std::string const &  desc = "" 
) [inline, explicit]

Constructor.

Parameters:
[in] module The module this task belongs to.
[in] name The name of the task, used by some functions who act on tasks by name. Set that if you don't intend to override the name() function.
[in] desc An arbitrary description of the task. Set that if you don't intend to * override the description() function.


Member Function Documentation

virtual bool scheduler::Task::poll (  )  [pure virtual]

Determines whether the task should be run. This function is called periodically by the Scheduler object to which the class has been added.

Returns:
true if the task should be run (in that case, run() is then called by the scheduler), false otherwise.
See also:
run()

Implemented in scheduler::TaskAlways, scheduler::TaskTimeout, and scheduler::TaskStep.

virtual int scheduler::Task::run (  )  [pure virtual]

Runs the task. Override this function to do whatever you want there.

Returns:
An or'ed combination of any of the rSlept, rRemove or rFree bits as appropriate. There is no error return value.
See also:
rSlept, rRemove, rRemoveFree

virtual std::string scheduler::Task::description (  )  const [inline, virtual]

Returns the description of the task. It can be used by the program to show information about the running task.

The default implementation returns the description specified in the constructor.

Returns:
The description of the task.

virtual std::string scheduler::Task::name (  )  const [inline, virtual]

Returns the name of the task. This name is used by the Scheduler::remove_bytype to remove tasks by type and name.

The default implementation returns the name specified in the constructor.

Returns:
The name of the task.
See also:
Scheduler::remove_bytype(int, std::string const &)


The documentation for this class was generated from the following file:
Generated on Fri Apr 18 22:03:29 2008 for Epona API by  doxygen 1.5.3