Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9665 in orxonox.OLD for trunk/src/lib/lang


Ignore:
Timestamp:
Aug 20, 2006, 11:39:18 PM (18 years ago)
Author:
bensch
Message:

trunk: iterator definitions

Location:
trunk/src/lib/lang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/new_class_id.h

    r9664 r9665  
    1212
    1313#include "new_object_list.h"
     14
     15
     16
    1417
    1518//! A class to dynamically allocate ClassID's and support a isA operator
  • trunk/src/lib/lang/new_object_list.h

    r9664 r9665  
    4040
    4141protected:
     42  class IteratorBase { };
     43
    4244  NewObjectListBase(const std::string& className);
    4345  ~NewObjectListBase();
     
    6870 * @note The Class must define the compare with const std::string& operator for this to work.
    6971 */
    70 template<class T> class NewObjectList : public NewObjectListBase
     72template<class T>
     73class NewObjectList : public NewObjectListBase
    7174{
    7275public:
    7376  typedef std::list<T*>               list;
    7477  typedef typename list::iterator     iterator;
     78
     79  class Iterator : public NewObjectListBase::IteratorBase
     80  {
     81  public:
     82    typename NewObjectList::iterator it;
     83  };
    7584
    7685public:
     
    8291
    8392  void registerObject(T* object);
    84   void unregisterObject(T* object);
     93  void unregisterObject(const IteratorBase& iterator);
    8594
    8695private:
     
    8897  NewObjectList(const NewObjectList& definer) {};
    8998
     99private:
    90100  list                _objects;
    91101};
    92102
     103
     104
     105
     106
     107/////////////////////////
     108//// IMPLEMENTATION /////
     109/////////////////////////
    93110template <class T>
    94111NewObjectList<T>::NewObjectList(const std::string& name)
     
    119136
    120137template <class T>
    121 void NewObjectList<T>::unregisterObject(T* object)
     138void NewObjectList<T>::unregisterObject(const IteratorBase& iterator)
    122139{
    123   _objects.erase(std::find(_objects.begin(), _objects.end(), object));
     140  this->_objects.erase(static_cast<Iterator>(iterator));
     141  //_objects.erase(std::find(_objects.begin(), _objects.end(), object));
    124142}
    125143
Note: See TracChangeset for help on using the changeset viewer.