Dragonfly  4.3
A text-based game engine
ObjectListIterator.h
1 ///
2 /// An iterator for ObjectLists
3 ///
4 
5 #ifndef __OBJECT_LIST_ITERATOR_H__
6 #define __OBJECT_LIST_ITERATOR_H__
7 
8 #include "Object.h"
9 #include "ObjectList.h"
10 
11 namespace df {
12 
13 class ObjectList;
14 
16 
17  private:
18  ObjectListIterator(); ///< Iterator must be given list when created.
19  int m_index; ///< Index into list.
20  const ObjectList *m_p_list; ///< List iterating over.
21 
22  public:
23  /// Create iterator, over indicated list.
24  ObjectListIterator(const ObjectList *p_list);
25 
26  /// Set iterator to first item in list.
27  void first();
28 
29  /// Set iterator to next item in list.
30  void next();
31 
32  /// Return true if at end of list.
33  bool isDone() const;
34 
35  /// Return pointer to current item in list, NULL if done/empty.
36  Object *currentObject() const;
37 
38  /// Assignment operator.
40 
41  /// Set to new List.
42  void setList(const ObjectList *p_list);
43 
44 };
45 
46 } // end of namespace df
47 #endif // __OBJECT_LIST_ITERATOR_H__
void first()
Set iterator to first item in list.
int m_index
Index into list.
Definition: ObjectListIterator.h:19
Definition: ObjectList.h:15
ObjectListIterator()
Iterator must be given list when created.
A 2-d bounding box.
Definition: Box.h:10
void setList(const ObjectList *p_list)
Set to new List.
Object * currentObject() const
Return pointer to current item in list, NULL if done/empty.
ObjectListIterator & operator=(const ObjectListIterator &rhs)
Assignment operator.
Definition: ObjectListIterator.h:15
Definition: Object.h:59
void next()
Set iterator to next item in list.
const ObjectList * m_p_list
List iterating over.
Definition: ObjectListIterator.h:20
bool isDone() const
Return true if at end of list.