Changeset 4935 in orxonox.OLD for orxonox/trunk/src/util
- Timestamp:
- Jul 22, 2005, 7:05:20 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/object_manager.h
r4934 r4935 34 34 35 35 //! A struct, that holds Lists of Objects of a certain type. 36 template <class T>struct FastObjectMember37 { 38 T*objectPointer;39 40 FastObjectMember <T>*next;36 struct FastObjectMember 37 { 38 BaseObject* objectPointer; 39 40 FastObjectMember* next; 41 41 }; 42 42 … … 81 81 unsigned int storedDeadObjects; //!< How many dead objects are stored in this class 82 82 83 FastObjectMember* deadList; //!< A List of all stored dead Objects of this class. 84 FastObjectMember* unusedContainers; //!< This is a List of unused containers, that will be reused by kill. 85 83 86 private: 84 87 static FastFactory* first; //!< A pointer to the first FastFactory. … … 107 110 108 111 private: 109 FastObjectMember<T>* deadList; //!< A List of all stored dead Objects of this class.110 FastObjectMember<T>* unusedContainers; //!< This is a List of unused containers, that will be reused by kill.111 112 112 }; 113 113 … … 144 144 T* tFastFactory<T>::fabricate() 145 145 { 146 FastObjectMember<T>* tmpFirstDead = new FastObjectMember<T>; 147 tmpFirstDead->objectPointer = new T(); 146 FastObjectMember* tmpFirstDead = new FastObjectMember; 147 T* fabricatedT = new T(); 148 tmpFirstDead->objectPointer = fabricatedT; 148 149 tmpFirstDead->next = this->deadList; 149 150 ++this->storedDeadObjects; 150 151 151 152 this->deadList = tmpFirstDead; 152 return tmpFirstDead->objectPointer;153 return fabricatedT; 153 154 } 154 155 … … 178 179 else 179 180 { 180 FastObjectMember <T>* tmpC = deadList;181 FastObjectMember* tmpC = deadList; 181 182 this->deadList = this->deadList->next; 182 183 … … 184 185 this->unusedContainers = tmpC; 185 186 186 return tmpC->objectPointer;187 return dynamic_cast<T*>(tmpC->objectPointer); 187 188 } 188 189 } … … 191 192 void tFastFactory<T>::kill(T* object) 192 193 { 193 FastObjectMember <T>* tmpC;194 FastObjectMember* tmpC; 194 195 if (unlikely(this->unusedContainers == NULL)) 195 196 { 196 tmpC = new FastObjectMember <T>;197 tmpC = new FastObjectMember; 197 198 } 198 199 else
Note: See TracChangeset
for help on using the changeset viewer.