qaf::ObjIterator< T > Class Template Reference

#include <qafEnvironment.h>

List of all members.


Detailed Description

template<typename T>
class qaf::ObjIterator< T >

Used to iterate over the Environment's list of active game objects.

Instances of this class are returned by Environment::makeObjIterator().

Note that there is no guarantee as to the order objects are returned by the iterator.

If you need to iterate over a specific class of object, use the template form:

    ObjIterator<YourClass> i = Environment::makeObjIterator<YourClass>();
    while ( i.hasNext() ) {
        YourClass * obj = i.next();
        // Do something with the object...
    }

Warning:
All active ObjIterators are invalidated at the end of a frame cycle; you must get a new ObjIterator every frame.
It is safe to use an ObjIterator along with the object manipulation methods (Environment::addGameObj(), Environment::removeGameObj(), Environment::moveGameObj()) and room management (Environment::loadRoom(), Environment::unloadRoom()), since those are buffered.


Public Member Functions

bool hasNext ()
 
Returns:
false if the end of the GameObj list has been reached.

T * next ()
 Retrieves the next object in the list and advances the pointer to the next object.
int getCount ()
 
Returns:
The total number of objects in this iterator.


Friends

class Environment


Member Function Documentation

template<typename T>
T* qaf::ObjIterator< T >::next (  )  [inline]

Retrieves the next object in the list and advances the pointer to the next object.

If the end of the object list has been reached, returns NULL.


The documentation for this class was generated from the following file:
Generated on Sun Mar 25 12:32:13 2007 for Qaf Framework by  doxygen 1.5.1-p1