Changeset 9671 in orxonox.OLD for trunk/src/lib/lang/new_object_list.h
- Timestamp:
- Aug 21, 2006, 4:14:57 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/new_object_list.h
r9667 r9671 11 11 #include <set> 12 12 #include <list> 13 #include <vector> 13 14 #include <string> 14 15 … … 33 34 34 35 /// Comparing operators. 35 bool compareName(const NewObjectListBase& more) { return this->_name < more.name(); }; 36 bool compareID(const NewObjectListBase& more) { return this->_id < more.id(); }; 36 bool compareName(const NewObjectListBase& more) const { return this->_name < more.name(); }; 37 bool compareID(const NewObjectListBase& more) const { return this->_id < more.id(); }; 38 39 virtual void debug() const = 0; 37 40 38 41 static unsigned int classCount() { return _idCounter; }; … … 42 45 static const std::list<std::string>& getClassNames(); 43 46 47 virtual void unregisterObject(std::list<NewObjectListBase::IteratorBase*> _iterators) = 0; 48 44 49 protected: 45 46 50 NewObjectListBase(const std::string& className); 47 ~NewObjectListBase();51 virtual ~NewObjectListBase(); 48 52 49 53 private: … … 52 56 static bool classNameExists(const std::string& className); 53 57 58 protected: 59 typedef std::set<NewObjectListBase*> cSet; //!< The Generic Set. 60 typedef std::vector<NewObjectListBase*> cVector; //!< The 61 62 int _id; //!< The ID of the class. 63 std::string _name; //!< The Name of the Class. 64 65 cVector _typeOfList; //!< A List of all classes this class is derived of, and the class itself, ordered by age of addition. 66 cSet _typeOfSet; //!< A Set of all classes this is derived from and the class itself (for isA). 54 67 private: 55 int _id;56 std::string _name;57 68 58 private: 59 typedef std::set<NewObjectListBase*> cList; 60 61 static int _idCounter; //!< A counter, that gives all classes a Unique ClassID. Access to this Variable is to be Thread-Safe. 62 static cList* _classes; //!< A Set of all the classes in existance. 63 static std::list<std::string> _classNames; //!< A list of all the registered ClassNames. 69 static int _idCounter; //!< A counter, that gives all classes a Unique ClassID. Access to this Variable is to be Thread-Safe. 70 static cSet* _classes; //!< A Set of all the classes in existance. 71 static std::list<std::string> _classNames; //!< A list of all the registered ClassNames. 64 72 }; 65 73 … … 76 84 { 77 85 public: 78 typedef std::list<T*> list; 79 typedef typename list::iterator iterator; 86 typedef std::list<T*> list; 87 typedef typename list::iterator iterator; 88 typedef typename list::const_iterator const_iterator; 80 89 81 90 class Iterator : public NewObjectListBase::IteratorBase … … 93 102 inline const list& objects() const { return _objects; }; 94 103 95 NewObjectListBase::IteratorBase* registerObject(T* object );104 NewObjectListBase::IteratorBase* registerObject(T* object, NewObjectListBase* objectList); 96 105 void unregisterObject(const IteratorBase& iterator); 106 virtual void unregisterObject(std::list<NewObjectListBase::IteratorBase*> _iterators) = 0; 107 108 virtual void debug() const; 97 109 98 110 private: … … 119 131 NewObjectList<T>::~NewObjectList() 120 132 { 121 // assert(_objects.empty());133 // assert(_objects.empty()); 122 134 } 123 135 … … 133 145 134 146 template <class T> 135 NewObjectListBase::IteratorBase* NewObjectList<T>::registerObject(T* object)147 NewObjectListBase::IteratorBase* NewObjectList<T>::registerObject(T* object, NewObjectListBase* objectList) 136 148 { 149 if(this->_typeOfList.empty()) 150 { 151 this->_typeOfList.push_back(objectList); 152 } 153 137 154 this->_objects.push_front(object); 138 155 return new Iterator(this->_objects.begin()); … … 146 163 } 147 164 165 #include <iostream> 166 167 template <class T> 168 void NewObjectList<T>::debug() const 169 { 170 const_iterator it; 171 for (it = this->_objects.begin(); it != this->_objects.end(); ++it) 172 { 173 std::cout << (*it)->name() << std::endl; 174 } 175 } 148 176 149 177 #endif /* _NEW_OBJECT_LIST_H */
Note: See TracChangeset
for help on using the changeset viewer.