![]() |
Dragonfly 2.2
A text-based game engine
|
00001 /// 00002 /// A list of Objects. 00003 /// 00004 00005 #ifndef __OBJECT_LIST_H__ 00006 #define __OBJECT_LIST_H__ 00007 00008 #define MAX_OBJECTS 5000 00009 00010 #include "Object.h" 00011 #include "ObjectListIterator.h" 00012 00013 class ObjectListIterator; 00014 00015 class ObjectList { 00016 00017 protected: 00018 int count; ///< Count of objects in list. 00019 Object *list[MAX_OBJECTS]; ///< Array of pointers to objects. 00020 00021 public: 00022 friend class ObjectListIterator; ///< Iterators can access. 00023 ObjectListIterator createIterator() const; ///< Create an iterator. 00024 00025 ObjectList(); 00026 ~ObjectList(); 00027 00028 /// Insert object pointer in list. 00029 /// Return 0 if ok, else -1. 00030 int insert(Object *p_o); 00031 00032 /// Remove object pointer from list, 00033 /// Return 0 if found, else -1. 00034 int remove(Object *p_o); 00035 00036 /// Clear the list (setting count to 0). 00037 void clear(); 00038 00039 /// Return pointer to object with indicated id, NULL of not found. 00040 Object *find(int id); 00041 00042 /// Return count of number of objects in list. 00043 int getCount(void); 00044 00045 /// Return true if list is empty, else false. 00046 bool isEmpty(); 00047 00048 /// Return true if list is full, else false. 00049 bool isFull(); 00050 00051 /// Adding two lists together appends second to first. 00052 ObjectList operator+(ObjectList); 00053 }; 00054 00055 #endif // __OBJECT_LIST_H__