Dragonfly 4.20
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
11namespace df {
12
13class ObjectListIterator;
14
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();
26
27 /// Copy contructor (does deep copy).
28 ObjectList(const ObjectList &other);
29
30 /// Assignment operator (does deep copy).
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 /// Add other ObjectList to this one.
58
59 /// Compare two lists.
60 bool operator==(const ObjectList &other) const;
61
62 /// Compare two lists.
63 bool operator!=(const ObjectList &other) const;
64
65 /// Index into list.
66 Object* &operator[](int index);
67};
68
69} // end of namespace df
70#endif // __OBJECT_LIST_H__
Definition: ObjectListIterator.h:15
Definition: ObjectList.h:15
void clear()
Clear list (setting count to 0).
int getCount() const
Return count of number of objects in list.
ObjectList(const ObjectList &other)
Copy contructor (does deep copy).
bool isFull() const
Return true if list is full, else false.
ObjectList operator+(ObjectList)
Add two lists, second appended to first.
Object *& operator[](int index)
Index into list.
int m_max_count
Maximum objects in list (variable).
Definition: ObjectList.h:19
ObjectList & operator+=(const ObjectList &other)
Add other ObjectList to this one.
bool operator!=(const ObjectList &other) const
Compare two lists.
int m_count
Count of objects in list.
Definition: ObjectList.h:18
int insert(Object *p_o)
Insert object pointer in list.
bool operator==(const ObjectList &other) const
Compare two lists.
Object ** p_item
Array of pointers to objects.
Definition: ObjectList.h:20
bool isEmpty() const
Return true if list is empty, else false.
int remove(Object *p_o)
Remove object pointer from list, Return 0 if found, else -1.
ObjectList & operator=(const ObjectList &rhs)
Assignment operator (does deep copy).
Definition: Object.h:57
An animation for a sprite.
Definition: Animation.h:15