Dragonfly  4.3
A text-based game engine
ObjectList.h
1 ///
2 /// A list of Objects
3 ///
4 
5 #ifndef __OBJECT_LIST_H__
6 #define __OBJECT_LIST_H__
7 
8 #include "Object.h"
9 #include "ObjectListIterator.h"
10 
11 namespace df {
12 
13 class ObjectListIterator;
14 
15 class ObjectList {
16 
17  private:
18  int m_count; ///< Count of objects in list.
19  int m_max_count; ///< Maximum objects in list (variable).
20  Object **p_item; ///< Array of pointers to objects.
21 
22  public:
23  friend class ObjectListIterator; ///< Iterators can access.
24  ObjectList();
25  ~ObjectList();
26 
27  /// Copy contructor (does deep copy).
28  ObjectList(const ObjectList &other);
29 
30  /// Assignment operator (does deep copy).
31  ObjectList &operator=(const ObjectList &rhs);
32 
33  /// Insert object pointer in list.
34  /// Return 0 if ok, else -1.
35  int insert(Object *p_o);
36 
37  /// Remove object pointer from list,
38  /// Return 0 if found, else -1.
39  int remove(Object *p_o);
40 
41  /// Clear list (setting count to 0).
42  void clear();
43 
44  /// Return count of number of objects in list.
45  int getCount() const;
46 
47  /// Return true if list is empty, else false.
48  bool isEmpty() const;
49 
50  /// Return true if list is full, else false.
51  bool isFull() const;
52 
53  /// Add two lists, second appended to first.
55 };
56 
57 } // end of namespace df
58 #endif // __OBJECT_LIST_H__
ObjectList & operator=(const ObjectList &rhs)
Assignment operator (does deep copy).
Object ** p_item
Array of pointers to objects.
Definition: ObjectList.h:20
Definition: ObjectList.h:15
A 2-d bounding box.
Definition: Box.h:10
bool isEmpty() const
Return true if list is empty, else false.
ObjectList operator+(ObjectList)
Add two lists, second appended to first.
int getCount() const
Return count of number of objects in list.
Definition: ObjectListIterator.h:15
Definition: Object.h:59
int m_max_count
Maximum objects in list (variable).
Definition: ObjectList.h:19
void clear()
Clear list (setting count to 0).
int insert(Object *p_o)
Insert object pointer in list.
int m_count
Count of objects in list.
Definition: ObjectList.h:18
bool isFull() const
Return true if list is full, else false.