Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9672 in orxonox.OLD for trunk/src/lib/lang/new_object_list.h


Ignore:
Timestamp:
Aug 21, 2006, 5:58:01 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: ClassList objectively implemented. This is not the fastest, but the most modular approach.
Now is the question of redundancy in code writing:
Should the ClassWriter explicitely declare a Class with superclasses, or should on runtime each object decide for itself, as it is done in BaseObject at the moment… questions questions questions…

File:
1 edited

Legend:

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

    r9671 r9672  
    2525public:
    2626  class IteratorBase { };
     27  struct ClassEntry{
     28    inline ClassEntry (NewObjectListBase* objectList, NewObjectListBase::IteratorBase* iterator) : _objectList(objectList), _iterator(iterator) {}
     29    NewObjectListBase*                _objectList;
     30    NewObjectListBase::IteratorBase*  _iterator;
     31  };
    2732
    2833public:
     
    4550  static const std::list<std::string>&  getClassNames();
    4651
    47   virtual void unregisterObject(std::list<NewObjectListBase::IteratorBase*> _iterators) = 0;
     52  virtual void unregisterObject(IteratorBase* _iterators) = 0;
    4853
    4954protected:
     
    9196  {
    9297  public:
    93     Iterator(iterator it) { it = it; }
    94     typename NewObjectList::iterator it;
     98    Iterator(iterator it) { _it = it; }
     99    inline iterator& it() { return _it; }
     100    typename NewObjectList::iterator _it;
    95101  };
    96102
     
    102108  inline const list&      objects() const { return _objects; };
    103109
    104   NewObjectListBase::IteratorBase* registerObject(T* object, NewObjectListBase* objectList);
    105   void unregisterObject(const IteratorBase& iterator);
    106   virtual void unregisterObject(std::list<NewObjectListBase::IteratorBase*> _iterators) = 0;
     110  NewObjectListBase::IteratorBase* registerObject(T* object);
     111  void unregisterObject(IteratorBase* iterator);
    107112
    108113  virtual void debug() const;
     
    145150
    146151template <class T>
    147     NewObjectListBase::IteratorBase* NewObjectList<T>::registerObject(T* object, NewObjectListBase* objectList)
     152    NewObjectListBase::IteratorBase* NewObjectList<T>::registerObject(T* object)
    148153{
    149   if(this->_typeOfList.empty())
    150   {
    151     this->_typeOfList.push_back(objectList);
    152   }
    153 
    154154  this->_objects.push_front(object);
    155155  return new Iterator(this->_objects.begin());
     
    157157
    158158template <class T>
    159 void NewObjectList<T>::unregisterObject(const IteratorBase& iterator)
     159void NewObjectList<T>::unregisterObject(IteratorBase* iterator)
    160160{
    161   this->_objects.erase(static_cast<Iterator>(iterator));
     161  this->_objects.erase(static_cast<Iterator*>(iterator)->it());
    162162  //_objects.erase(std::find(_objects.begin(), _objects.end(), object));
    163163}
Note: See TracChangeset for help on using the changeset viewer.