TaskManager Class Reference

Holder of all runing tasks. More...

#include <taskmanager.h>

Inherits Task.

Inheritance diagram for TaskManager:

Inheritance graph
[legend]
Collaboration diagram for TaskManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TaskManager ()
 ~TaskManager ()
void add (Task &task)
 Add task to list of tasks - as last.
void remove (Task &task)
 Remove task from task list.
void initTasks ()
 Inicialize all tasks.
void cleanTasks ()
 Clean all tasks.
void update (bool savecpu=true)
 Update all tasks.
virtual void update (int atime)
 Upate callback it taskmanager is part of other task manager.
virtual void addedWorldObject (WorldEntity *we)
 Notify all tasks, that entity was added.
virtual void deletedWorldObject (WorldEntity *we)
 Notify all tastks, that entity will be deleted.

Private Attributes

int mLastUpdate
std::list< Task * > mTaskList
 List to hold all tasks.

Detailed Description

Holder of all runing tasks.

Every runing task should be added to this task manager. The task manager call update to tasks and notify them about new/deleted objects in game.

The task manager is also Task so you may include more manager into one tree. (don't do cycles :-)

Definition at line 20 of file taskmanager.h.


Constructor & Destructor Documentation

TaskManager::TaskManager  ) 
 

Definition at line 17 of file taskmanager.cpp.

TaskManager::~TaskManager  ) 
 

Definition at line 21 of file taskmanager.cpp.


Member Function Documentation

void TaskManager::add Task task  ) 
 

Add task to list of tasks - as last.

You should add all tasks before using anything ither from TaskManager. Multiple calls with will add task mutiple times!

Parameters:
task reference to task that will be added

Definition at line 26 of file taskmanager.cpp.

References mTaskList.

Referenced by ApplicationServer::init(), ApplicationClient::init(), GameServer::run(), and GameClient::run().

void TaskManager::addedWorldObject WorldEntity we  )  [virtual]
 

Notify all tasks, that entity was added.

Parameters:
we pointer to newly added entity

Reimplemented from Task.

Definition at line 119 of file taskmanager.cpp.

References assertL, mTaskList, and TIN.

void TaskManager::cleanTasks  ) 
 

Clean all tasks.

Die if any failure. Maybe we could be a less strict in final version and accept errors in cleaning :-)

Definition at line 105 of file taskmanager.cpp.

References assertL, mTaskList, and TIN.

Referenced by GameClient::run().

void TaskManager::deletedWorldObject WorldEntity we  )  [virtual]
 

Notify all tastks, that entity will be deleted.

Parameters:
we pointer to entity that will be deleted

Reimplemented from Task.

Definition at line 132 of file taskmanager.cpp.

References assertL, mTaskList, and TIN.

void TaskManager::initTasks  ) 
 

Inicialize all tasks.

Die if any failure. Must be called before any calls to update.

Definition at line 46 of file taskmanager.cpp.

References assertL, mTaskList, and TIN.

Referenced by GameServer::run(), and GameClient::run().

void TaskManager::remove Task task  ) 
 

Remove task from task list.

If the task was added mutiple times only one is removed.

Parameters:
task task to remove

Definition at line 31 of file taskmanager.cpp.

References assertL, and mTaskList.

Referenced by GameClient::run().

void TaskManager::update int  atime  )  [virtual]
 

Upate callback it taskmanager is part of other task manager.

Equal to update(fale)

Parameters:
atime only for interface. Not used.

Reimplemented from Task.

Definition at line 100 of file taskmanager.cpp.

References update().

Here is the call graph for this function:

void TaskManager::update bool  savecpu = true  ) 
 

Update all tasks.

This shoul be often called from Engine. Since most of all game is done here.

Parameters:
savecpu if true the task manager will sleep a little if called to often not to waste cpu

Definition at line 69 of file taskmanager.cpp.

References assertL, TimeManager::getTicks(), mTaskList, and TIN.

Referenced by GameServer::run(), GameClient::run(), and update().

Here is the call graph for this function:


Member Data Documentation

int TaskManager::mLastUpdate [private]
 

Definition at line 95 of file taskmanager.h.

std::list<Task*> TaskManager::mTaskList [private]
 

List to hold all tasks.

Definition at line 97 of file taskmanager.h.

Referenced by add(), addedWorldObject(), cleanTasks(), deletedWorldObject(), initTasks(), remove(), and update().


The documentation for this class was generated from the following files:
Generated on Wed Apr 12 14:26:06 2006 for bjs by  doxygen 1.4.5