Changeset 9664 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Aug 20, 2006, 7:50:38 PM (18 years ago)
- Location:
- trunk/src/lib/lang
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/new_class_id.cc
r9660 r9664 26 26 */ 27 27 NewClassID::NewClassID () 28 : _ className("")28 : _objectList(NULL) 29 29 {} 30 30 … … 35 35 NewClassID::~NewClassID () 36 36 { 37 // delete what has to be deleted here 37 assert(_objectList != NULL); 38 39 // _objectList->unregister(this); 38 40 } 39 41 -
trunk/src/lib/lang/new_class_id.h
r9663 r9664 9 9 10 10 #include "type_info.h" 11 #include <set>12 11 #include <string> 13 12 … … 21 20 ~NewClassID(); 22 21 23 void registerObject(NewObjectListBase* object);22 template<class T> void registerObject(T* object, NewObjectList<T>& list); 24 23 25 24 private: 26 std::string _className; 27 25 NewObjectListBase* _objectList; 28 26 }; 29 27 30 28 29 template<class T> void NewClassID::registerObject(T* object, NewObjectList<T>& objectList) 30 { 31 this->_objectList = &objectList; 32 objectList.registerObject(object); 33 } 34 31 35 #endif /* _NEW_CLASS_ID_H */ -
trunk/src/lib/lang/new_object_list.cc
r9663 r9664 29 29 this->_id = NewObjectListBase::_idCounter++; 30 30 31 32 31 } 33 32 -
trunk/src/lib/lang/new_object_list.h
r9663 r9664 32 32 bool compareName(const NewObjectListBase& more) { return this->_name < more.name(); }; 33 33 bool compareID(const NewObjectListBase& more) { return this->_id < more.id(); }; 34 35 34 36 35 static unsigned int classCount() { return _idCounter; }; … … 75 74 typedef typename list::iterator iterator; 76 75 77 78 76 public: 79 77 NewObjectList(const std::string& name); … … 83 81 inline const list& objects() const { return _objects; }; 84 82 83 void registerObject(T* object); 84 void unregisterObject(T* object); 85 85 86 86 private: … … 112 112 } 113 113 114 template <class T> 115 void NewObjectList<T>::registerObject(T* object) 116 { 117 this->_objects.push_back(object); 118 } 119 120 template <class T> 121 void NewObjectList<T>::unregisterObject(T* object) 122 { 123 _objects.erase(std::find(_objects.begin(), _objects.end(), object)); 124 } 125 126 114 127 #endif /* _NEW_OBJECT_LIST_H */
Note: See TracChangeset
for help on using the changeset viewer.