Changeset 9702 in orxonox.OLD for branches/new_class_id
- Timestamp:
- Aug 25, 2006, 11:54:18 AM (18 years ago)
- Location:
- branches/new_class_id/src/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/lang/new_object_list.h
r9701 r9702 13 13 #include <string> 14 14 #include <iostream> 15 16 17 15 18 16 /** … … 70 68 virtual void unregisterObject(IteratorBase* _iterators) = 0; 71 69 70 public: 71 typedef std::list<BaseObject*> base_list; 72 typedef std::list<BaseObject*>::iterator base_iterator; 73 74 virtual void getBaseObjectList(base_list* list) const = 0; 75 76 static const NewObjectListBase* const getObjectList(int classID); 77 static const NewObjectListBase* const getObjectList(const std::string& className); 78 static const NewObjectListBase* const getObjectList(const NewClassID& classID); 79 80 static BaseObject* getBaseObject(int classID, const std::string& objectName); 81 static BaseObject* getBaseObject(const std::string& className, const std::string& objectName); 82 static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName); 83 84 virtual BaseObject* getBaseObject(const std::string& name) const = 0; 85 72 86 protected: 73 87 NewObjectListBase(const std::string& className, int id = -1); … … 80 94 static bool classNameExists(const std::string& className); 81 95 82 public:83 class base_iterator84 {85 public:86 /// @NOTE Do not use this class. For internal handling.87 class __base_iterator_base88 {89 public:90 virtual void operator++(int) = 0;91 virtual void operator++() = 0;92 virtual void operator--(int) = 0;93 virtual void operator--() = 0;94 virtual BaseObject* operator*() = 0;95 virtual __base_iterator_base* operator=(const __base_iterator_base& iterator) = 0;96 virtual bool operator==(const __base_iterator_base& iterator) const = 0;97 virtual bool operator!=(const __base_iterator_base& iterator) const = 0;98 virtual __base_iterator_base* clone() const;99 };100 101 public:102 base_iterator(const __base_iterator_base& it) { _it = it.clone(); };103 ~base_iterator() { delete _it; }104 void operator++() { (*_it)++; };105 void operator++(int) { ++(*_it); };106 void operator--() { (*_it)--; };107 void operator--(int) { --(*_it); };108 BaseObject* operator*() { return *(*_it); };109 base_iterator& operator=(const base_iterator& iterator);110 bool operator==(const base_iterator& iter) const { return *this->_it == *iter._it; };111 bool operator!=(const base_iterator& iter) const { return *this->_it != *iter._it; };112 113 private:114 __base_iterator_base* _it;115 };116 117 virtual base_iterator base_begin() const = 0;118 virtual base_iterator base_end() const = 0;119 120 static const NewObjectListBase* const getObjectList(int classID);121 static const NewObjectListBase* const getObjectList(const std::string& className);122 static const NewObjectListBase* const getObjectList(const NewClassID& classID);123 124 static BaseObject* getBaseObject(int classID, const std::string& objectName);125 static BaseObject* getBaseObject(const std::string& className, const std::string& objectName);126 static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName);127 128 virtual BaseObject* getBaseObject(const std::string& name) const = 0;129 96 130 97 protected: … … 162 129 typedef typename list::iterator iterator; 163 130 typedef typename list::const_iterator const_iterator; 164 165 virtual base_iterator base_begin() const { return base_iterator(__base_iterator(this->_objects.begin())); };166 virtual base_iterator base_end() const { return base_iterator(__base_iterator(this->_objects.end())); };167 131 168 132 … … 199 163 200 164 protected: 201 class __base_iterator : public base_iterator::__base_iterator_base 202 { 203 public: 204 __base_iterator(const const_iterator& iter); 205 void operator++(int) { ++_iter; }; 206 void operator++() { _iter++; }; 207 void operator--(int) { --_iter; }; 208 void operator--() { _iter--; }; 209 BaseObject* operator*() { return *_iter; }; 210 base_iterator::__base_iterator_base* operator=(const __base_iterator_base& iterator) { this->_iter = static_cast<const __base_iterator&>(iterator)._iter; return this; }; 211 bool operator==(const __base_iterator_base& iterator) const { return _iter == static_cast<const __base_iterator&>(iterator)._iter; }; 212 bool operator!=(const __base_iterator_base& iterator) const { return _iter != static_cast<const __base_iterator&>(iterator)._iter; }; 213 private: 214 const_iterator _iter; 215 }; 165 virtual void getBaseObjectList(NewObjectListBase::base_list* list) const; 166 216 167 217 168 private: … … 282 233 283 234 /** 235 * @brief retrieves a List of BaseObjects 236 * @param list the list to push the ObjectList into. 237 */ 238 template <class T> 239 void NewObjectList<T>::getBaseObjectList(NewObjectListBase::base_list* list) const 240 { 241 assert (list != NULL); 242 const_iterator it; 243 for (it = this->_objects.begin(); it != this->_objects.end(); ++it) 244 list->push_back(*it); 245 } 246 247 248 /** 284 249 * @brief registers an Object to the NewObjectList. 285 250 * @param T object the Object to register. -
branches/new_class_id/src/lib/shell/shell_command.cc
r9697 r9702 244 244 if (objectList != NULL) 245 245 { 246 NewObjectListBase::base_iterator bo(objectList->base_begin()); 246 NewObjectListBase::base_list list; 247 objectList->getBaseObjectList(&list); 248 NewObjectListBase::base_iterator it; 247 249 248 250 // No Description given (only for speedup) 249 251 if (objectDescriptor.empty()) 250 252 { 251 for ( ; bo != objectList->base_end(); bo++)252 boList->push_back(* bo);253 for (it = list.begin(); it != list.end(); it++) 254 boList->push_back(*it); 253 255 } 254 256 // some description 255 257 else 256 258 { 257 for ( bo = objectList->base_begin(); bo != objectList->base_end(); bo++)258 if (!nocaseCmp(objectDescriptor, (* bo)->getName(), objectDescriptor.size()))259 boList->push_back(* bo);259 for (it = list.begin(); it != list.end(); it++) 260 if (!nocaseCmp(objectDescriptor, (*it)->getName(), objectDescriptor.size())) 261 boList->push_back(*it); 260 262 } 261 263 }
Note: See TracChangeset
for help on using the changeset viewer.