Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9693 in orxonox.OLD for branches


Ignore:
Timestamp:
Aug 23, 2006, 8:44:58 PM (18 years ago)
Author:
bensch
Message:

new_class_id: syncing the IteratorClass

Location:
branches/new_class_id/src/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/effects/atmospheric_engine.cc

    r9685 r9693  
    2323#include "util/loading/factory.h"
    2424
    25 NewObjectListDefinition(AtmosphericEngine);
     25NewObjectListDefinitionID(AtmosphericEngine, CL_ATMOS_ENGINE);
    2626
    2727/**
  • branches/new_class_id/src/lib/lang/new_object_list.h

    r9692 r9693  
    4444{
    4545public:
    46   class base_iterator
    47   {
    48   public:
    49     virtual base_iterator operator++() = 0;
    50     virtual base_iterator operator--() = 0;
    51     virtual BaseObject* operator*() = 0;
    52     virtual base_iterator& operator=(const base_iterator& iterator) = 0;
    53     virtual bool operator==(const base_iterator& iterator) = 0;
    54   protected:
    55     void* _it;
    56   };
    57 
    58   virtual base_iterator& base_begin() = 0;
    59   virtual base_iterator& base_end() = 0;
    60 
    6146  //! A fast iterator Base-Class, for iterator-casting and storing.
    6247  /**
     
    9378  static bool classNameExists(const std::string& className);
    9479
     80public:
     81  class base_iterator
     82  {
     83  public:
     84    /// @NOTE Do not use this class. For internal handling.
     85    class __base_iterator_base
     86    {
     87    public:
     88      virtual void operator++(int) = 0;
     89      virtual void operator++() = 0;
     90      virtual void operator--(int) = 0;
     91      virtual void operator--() = 0;
     92      virtual BaseObject* operator*() = 0;
     93      virtual __base_iterator_base& operator=(const base_iterator& iterator) = 0;
     94      virtual bool operator==(const __base_iterator_base& iterator) const = 0;
     95      virtual bool operator!=(const __base_iterator_base& iterator) const = 0;
     96      virtual __base_iterator_base* clone() const;
     97    };
     98
     99  public:
     100    base_iterator(__base_iterator_base& it) { _it = it.clone(); };
     101    ~base_iterator() { delete _it; }
     102    void operator++() { (*_it)++; };
     103    void operator++(int) { ++(*_it); };
     104    void operator--() { (*_it)--; };
     105    void operator--(int) { --(*_it); };
     106    BaseObject* operator*() { return *(*_it); };
     107    base_iterator& operator=(const base_iterator& iterator);
     108    bool operator==(const base_iterator& iter) const { return *this->_it == *iter._it; };
     109    bool operator!=(const base_iterator& iter) const { return *this->_it != *iter._it; };
     110
     111  private:
     112    __base_iterator_base*    _it;
     113  };
     114
     115  virtual base_iterator base_begin() const = 0;
     116  virtual base_iterator base_end() const = 0;
     117
     118
    95119protected:
    96120  typedef std::map<int, NewObjectListBase*>         classIDMap;   //!< The Generic Map.
     
    126150  typedef typename list::const_iterator  const_iterator;
    127151
    128   virtual base_iterator& base_begin() { };
    129   virtual base_iterator& base_end() { };
     152  virtual base_iterator base_begin() const { return base_iterator(__base_iterator(this->_objects.begin())); };
     153  virtual base_iterator base_end() const { return base_iterator(__base_iterator(this->_objects.end())); };
    130154
    131155
     
    159183
    160184  virtual void debug() const;
     185
     186protected:
     187class __base_iterator : public base_iterator::__base_iterator_base
     188  {
     189  public:
     190    __base_iterator(const const_iterator& iter);
     191    void operator++(int) { ++_iter; };
     192    void operator++()  { _iter++; };
     193    void operator--(int) { --_iter; };
     194    void operator--()  { _iter--; };
     195    BaseObject* operator*() { return *iter; };
     196    base_iterator::__base_iterator_base& operator=(const base_iterator& iterator) { _iter = iterator._iter; return *this; };
     197    bool operator==(const __base_iterator_base& iterator) const { return _iter == iterator._iter; };
     198    bool operator!=(const __base_iterator_base& iterator) const { return _iter != iterator._iter; };
     199  private:
     200    iterator _iter;
     201  };
    161202
    162203private:
Note: See TracChangeset for help on using the changeset viewer.