Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1591 for code/branches/core3


Ignore:
Timestamp:
Jun 12, 2008, 2:00:15 AM (16 years ago)
Author:
landauf
Message:

Again some heavy changes in ObjectList and Iterator:
there are now two types of iterators:

Iterator<ClassName> can iterate through any objectlist, either given by ObjectList<AnyClassName>::begin() or anyidentifier→getObjects()→begin(). Important note Iterator<ClassName> uses dynamic_cast.
And yes, it's possible to do this: Iterator<WorldEntity> it = ObjectList<SpaceShip>::begin()

ObjectList<ClassName>::iterator is the second iterator - it uses the ObjectList in a templated manner and therefore doesn't need dynamic_cast. But the only thing you can do is iterating through exactly the right ObjectList: ObjectList<ClassName>::iterator it = ObjectList<ClassName>::begin(). Anything else fails.

Those changes bring, at my system, something around +12% FPS compared with trunk and +25% FPS compared with the last revision of core3. Although I have to admit the FPS gain is only that high because iterating through objects is the main thing we're doing ingame right now. It would look totally different with physics, sound, AI, scripts, triggers and so on.

Location:
code/branches/core3/src
Files:
1 added
1 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/CorePrereqs.h

    r1586 r1591  
    138138  class ObjectListBase;
    139139  class ObjectListBaseElement;
     140  template <class T>
     141  class ObjectListElement;
     142  template <class T>
     143  class ObjectListIterator;
    140144  class OrxonoxClass;
    141145  class Shell;
     
    153157  class XMLPortObjectContainer;
    154158  class XMLPortParamContainer;
     159
     160  struct ObjectListBase::Export;
    155161
    156162  // input
  • code/branches/core3/src/core/Identifier.cc

    r1583 r1591  
    3939#include "ConsoleCommand.h"
    4040#include "CommandExecutor.h"
    41 #include "MetaObjectList.h"
     41#include "Iterator.h"
    4242#include "ObjectList.h"
    4343#include "OrxonoxClass.h"
     
    197197
    198198    /**
    199         @brief Adds an object of the given type to the ObjectList.
    200         @param object The object to add
    201     */
    202     void Identifier::addObject(OrxonoxClass* object)
    203     {
    204         COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    205         object->getMetaList().add(this->objects_, this->objects_->add(object));
     199        @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function.
     200    */
     201    void Identifier::updateConfigValues() const
     202    {
     203        for (BaseIterator it = this->getObjects()->begin(); it; ++it)
     204            (*it)->setConfigValues();
    206205    }
    207206
  • code/branches/core3/src/core/Identifier.h

    r1586 r1591  
    6060#include <utility>
    6161
    62 #include "Iterator.h"
     62#include "MetaObjectList.h"
     63#include "ObjectListBase.h"
    6364#include "util/Debug.h"
    6465#include "util/String.h"
     
    103104            bool isDirectParentOf(const Identifier* identifier) const;
    104105
    105             void addObject(OrxonoxClass* object);
    106 
    107106            /** @brief Returns the list of all existing objects of this class. @return The list */
    108107            inline ObjectListBase* getObjects() const
     
    113112            void setName(const std::string& name);
    114113
    115             virtual void updateConfigValues() const = 0;
     114            void updateConfigValues() const;
    116115
    117116            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
     
    231230
    232231            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
     232            ObjectListBase* objects_;                                      //!< The list of all objects of this class
    233233
    234234        private:
     
    264264            bool bSetName_;                                                //!< True if the name is set
    265265            std::string name_;                                             //!< The name of the class the Identifier belongs to
    266             ObjectListBase* objects_;                                      //!< The list of all objects of this class
    267266            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
    268267            static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
     
    301300            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
    302301            static bool isFirstCall();
    303 
    304             void updateConfigValues() const;
     302            void addObject(T* object);
    305303
    306304            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
     
    411409
    412410    /**
    413         @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function.
    414     */
    415     template <class T>
    416     void ClassIdentifier<T>::updateConfigValues() const
    417     {
    418         for (Iterator<T> it = this->getObjects()->begin(); it; ++it)
    419             (*it)->setConfigValues();
     411        @brief Adds an object of the given type to the ObjectList.
     412        @param object The object to add
     413    */
     414    template <class T>
     415    void ClassIdentifier<T>::addObject(T* object)
     416    {
     417        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
     418        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
    420419    }
    421420
  • code/branches/core3/src/core/Iterator.h

    r1574 r1591  
    3131    @brief Definition and implementation of the Iterator class.
    3232
    33     The Iterator of a given class allows to iterate through an ObjectList, containing all objects of that type.
    34     This is the only way to access the objects stored in an ObjectList.
     33    The Iterator of a given class allows to iterate through an ObjectList. Objects in
     34    this list are casted to the template argument of the Iterator.
    3535
    3636    Usage:
    37     for (Iterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it)
     37    for (Iterator<myClass> it = anyidentifier->getObjects().begin(); it != anyidentifier->getObjects().end(); ++it)
    3838    {
    3939        it->someFunction(...);
     
    4747#include "CorePrereqs.h"
    4848
    49 #include "IteratorBase.h"
     49#include "ObjectListBase.h"
     50#include "ObjectListIterator.h"
     51#include "OrxonoxClass.h"
    5052
    5153namespace orxonox
    5254{
    53     //! The Iterator allows to iterate through the ObjectList of a given class.
    54     template <class T>
    55     class Iterator : public IteratorBase
     55    //! The Iterator allows to iterate through a given ObjectList
     56    template <class T = OrxonoxClass>
     57    class Iterator
    5658    {
    5759        public:
     
    6163            inline Iterator()
    6264            {
    63                 ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
    64             }
    65 
    66             /**
    67                 @brief Constructor: Sets the element, whereon the iterator points, to a given element.
    68                 @param element The element to start with
    69             */
    70             inline Iterator(ObjectListBaseElement* element) : IteratorBase((ObjectListBaseElement*)element)
    71             {
    72                 ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
     65                this->element_ = 0;
     66                this->list_ = 0;
     67            }
     68
     69            /**
     70                @brief Constructor: Sets this element to the exported element.
     71                @param exp The exported element
     72            */
     73            inline Iterator(const ObjectListBase::Export& exp)
     74            {
     75                this->element_ = exp.element_;
     76                this->list_ = exp.list_;
     77                this->iterator_ = this->list_->registerIterator(this);
     78            }
     79
     80            /**
     81                @brief Constructor: Sets this element to the element of another Iterator.
     82                @param other The other Iterator
     83            */
     84            inline Iterator(const Iterator<T>& other)
     85            {
     86                this->element_ = other.element_;
     87                this->list_ = other.list_;
     88                this->iterator_ = this->list_->registerIterator(this);
     89            }
     90
     91            /**
     92                @brief Constructor: Sets this element to a given element
     93                @param element The element
     94            */
     95            template <class O>
     96            inline Iterator(ObjectListElement<O>* element)
     97            {
     98                this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
     99                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
     100                this->iterator_ = this->list_->registerIterator(this);
     101            }
     102
     103            /**
     104                @brief Constructor: Sets this element to the element an ObjectListIterator.
     105                @param other The ObjectListIterator
     106            */
     107            template <class O>
     108            inline Iterator(const ObjectListIterator<O>& other)
     109            {
     110                this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
     111                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
     112                this->iterator_ = this->list_->registerIterator(this);
    73113            }
    74114
     
    78118            inline ~Iterator()
    79119            {
    80                 ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterIterator(this);
     120                this->list_->unregisterIterator(this->iterator_);
     121            }
     122
     123            /**
     124                @brief Assigns an exported element.
     125                @param exp The exported element
     126            */
     127            inline const Iterator<T>& operator=(const ObjectListBase::Export& exp)
     128            {
     129                if (this->list_)
     130                    this->list_->unregisterIterator(this->iterator_);
     131
     132                this->element_ = exp.element_;
     133                this->list_ = exp.list_;
     134                this->iterator_ = this->list_->registerIterator(this);
     135
     136                return (*this);
     137            }
     138
     139            /**
     140                @brief Assigns the element of another Iterator.
     141                @param other The other Iterator
     142            */
     143            inline const Iterator<T>& operator=(const Iterator<T>& other)
     144            {
     145                if (this->list_)
     146                    this->list_->unregisterIterator(this->iterator_);
     147
     148                this->element_ = other.element_;
     149                this->list_ = other.list_;
     150                this->iterator_ = this->list_->registerIterator(this);
     151
     152                return (*this);
     153            }
     154
     155            /**
     156                @brief Assigns a given element.
     157                @param element The element
     158            */
     159            template <class O>
     160            inline const Iterator<T>& operator=(ObjectListElement<O>* element)
     161            {
     162                if (this->list_)
     163                    this->list_->unregisterIterator(this->iterator_);
     164
     165                this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
     166                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
     167                this->iterator_ = this->list_->registerIterator(this);
     168
     169                return (*this);
     170            }
     171
     172            /**
     173                @brief Assigns the element of an ObjectListIterator.
     174                @param other The ObjectListIterator
     175            */
     176            template <class O>
     177            inline const Iterator<T>& operator=(const ObjectListIterator<O>& other)
     178            {
     179                if (this->list_)
     180                    this->list_->unregisterIterator(this->iterator_);
     181
     182                this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
     183                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
     184                this->iterator_ = this->list_->registerIterator(this);
     185
     186                return (*this);
    81187            }
    82188
     
    85191                @return The Iterator itself
    86192            */
    87             inline Iterator<T> operator++()
    88             {
    89                 IteratorBase::operator++();
     193            inline const Iterator<T>& operator++()
     194            {
     195                if (this->element_)
     196                    this->element_ = this->element_->next_;
    90197                return *this;
    91198            }
     
    98205            {
    99206                Iterator<T> copy = *this;
    100                 IteratorBase::operator++();
     207                if (this->element_)
     208                    this->element_ = this->element_->next_;
    101209                return copy;
    102210            }
     
    106214                @return The Iterator itself
    107215            */
    108             inline Iterator<T> operator--()
    109             {
    110                 IteratorBase::operator--();
     216            inline const Iterator<T>& operator--()
     217            {
     218                if (this->element_)
     219                    this->element_ = this->element_->prev_;
    111220                return *this;
    112221            }
     
    119228            {
    120229                Iterator<T> copy = *this;
    121                 IteratorBase::operator--();
     230                if (this->element_)
     231                    this->element_ = this->element_->prev_;
    122232                return copy;
    123233            }
     
    127237                @return The object the Iterator points at
    128238            */
    129             inline T* operator*()
    130             {
    131                 return dynamic_cast<T*>(IteratorBase::operator*());
     239            inline T* operator*() const
     240            {
     241                if (this->element_)
     242                    return dynamic_cast<T*>(this->element_->objectBase_);
     243                else
     244                    return 0;
    132245            }
    133246
     
    138251            inline T* operator->() const
    139252            {
    140                 return dynamic_cast<T*>(IteratorBase::operator->());
     253                if (this->element_)
     254                    return dynamic_cast<T*>(this->element_->objectBase_);
     255                else
     256                    return 0;
     257            }
     258
     259            /**
     260                @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
     261                @return True if the Iterator points to an existing object.
     262            */
     263            inline operator bool() const
     264            {
     265                return (this->element_ != 0);
    141266            }
    142267
     
    146271                @return True if the iterators point to the same element
    147272            */
    148             inline bool operator==(const Iterator<T>& compare)
     273            inline bool operator==(const Iterator<T>& compare) const
    149274            {
    150275                return (this->element_ == compare.element_);
     
    156281                @return True if the iterators point to different elements
    157282            */
    158             inline bool operator!=(const Iterator<T>& compare)
     283            inline bool operator!=(const Iterator<T>& compare) const
    159284            {
    160285                return (this->element_ != compare.element_);
    161286            }
     287
     288            /**
     289                @brief Increments the Iterator if it points at the given object.
     290                @param object The object to compare with
     291            */
     292            inline void incrementIfEqual(OrxonoxClass* object)
     293            {
     294                if (this->element_ && this->element_->objectBase_ == object)
     295                    this->operator++();
     296            }
     297
     298        protected:
     299            ObjectListBaseElement* element_;       //!< The element the Iterator points at
     300            ObjectListBase* list_;                 //!< The list wherein the element is
     301            std::list<void*>::iterator iterator_;  //!< The iterator in the notifying list of the ObjectList
    162302    };
     303
     304    typedef Iterator<OrxonoxClass> BaseIterator;
    163305}
    164306
  • code/branches/core3/src/core/MetaObjectList.cc

    r1586 r1591  
    3333
    3434#include "MetaObjectList.h"
     35#include "ObjectListBase.h"
     36#include "Identifier.h"
    3537#include "util/Debug.h"
    3638
     
    4648    {
    4749        COUT(5) << "*** MetaObjectList: Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << std::endl;
    48         this->list_->notifyIterators(this->element_);
     50        this->list_->notifyIterators(this->element_->objectBase_);
    4951
    5052        if (this->element_->next_)
  • code/branches/core3/src/core/MetaObjectList.h

    r1574 r1591  
    4040
    4141#include "CorePrereqs.h"
    42 
    43 #include "ObjectListBase.h"
    44 #include "Identifier.h"
    4542
    4643namespace orxonox
  • code/branches/core3/src/core/ObjectList.h

    r1574 r1591  
    4141
    4242#include "Identifier.h"
    43 #include "Iterator.h"
     43#include "ObjectListIterator.h"
    4444
    4545namespace orxonox
     
    5151    /**
    5252        Wraps the ObjectListBase of the corresponding Identifier.
    53         Use Iterator<class> to iterate through all objects in the list.
     53        Use ObjectListIterator<class> to iterate through all objects in the list.
    5454    */
    5555    template <class T>
     
    5757    {
    5858        public:
     59            typedef ObjectListIterator<T> iterator;
     60
    5961            /** @brief Returns an Iterator to the first element in the list. @return The Iterator */
    60             inline static Iterator<T> begin()
    61                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->begin()); }
     62            inline static ObjectListElement<T>* begin()
     63                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->begin().element_); }
    6264
    6365            /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */
    64             inline static Iterator<T> end()
    65                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->end()); }
     66            inline static ObjectListElement<T>* end()
     67                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->end().element_); }
    6668
    6769            /** @brief Returns an Iterator to the last element in the list. @return The Iterator */
    68             inline static Iterator<T> rbegin()
    69                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin()); }
     70            inline static ObjectListElement<T>* rbegin()
     71                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin().element_); }
    7072
    7173            /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */
    72             inline static Iterator<T> rend()
    73                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->rend()); }
     74            inline static ObjectListElement<T>* rend()
     75                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rend().element_); }
    7476    };
    7577}
  • code/branches/core3/src/core/ObjectListBase.cc

    r1574 r1591  
    4141#include "ObjectListBase.h"
    4242#include "Identifier.h"
    43 #include "IteratorBase.h"
     43#include "Iterator.h"
    4444
    4545namespace orxonox
     
    7373        @param element The element that gets removed
    7474    */
    75     void ObjectListBase::notifyIterators(ObjectListBaseElement* element)
     75    void ObjectListBase::notifyIterators(OrxonoxClass* object) const
    7676    {
    77         for (std::set<IteratorBase*>::iterator it = this->iterators_.begin(); it != this->iterators_.end(); ++it)
    78             if ((*(*(*it))) == element->object_)
    79                 ++(*(*it));
     77        for (std::list<void*>::const_iterator it = this->iterators_.begin(); it != this->iterators_.end(); ++it)
     78            ((Iterator<OrxonoxClass>*)(*it))->incrementIfEqual(object);
     79        for (std::list<void*>::const_iterator it = this->objectListIterators_.begin(); it != this->objectListIterators_.end(); ++it)
     80            ((ObjectListIterator<OrxonoxClass>*)(*it))->incrementIfEqual(object);
    8081    }
    8182
     
    8586        @return The pointer to the new ObjectListBaseElement, needed by the MetaObjectList of the added object
    8687    */
    87     ObjectListBaseElement* ObjectListBase::add(OrxonoxClass* object)
     88    ObjectListBaseElement* ObjectListBase::add(ObjectListBaseElement* element)
    8889    {
    8990        if (!this->last_)
    9091        {
    9192            // If the list is empty
    92             this->last_ = new ObjectListBaseElement(object);
     93            this->last_ = element;
    9394            this->first_ = this->last_; // There's only one object in the list now
    9495        }
     
    9798            // If the list isn't empty
    9899            ObjectListBaseElement* temp = this->last_;
    99             this->last_ = new ObjectListBaseElement(object);
     100            this->last_ = element;
    100101            this->last_->prev_ = temp;
    101102            temp->next_ = this->last_;
  • code/branches/core3/src/core/ObjectListBase.h

    r1574 r1591  
    3838#define _ObjectListBase_H__
    3939
    40 #include <set>
     40#include <list>
    4141
    4242#include "CorePrereqs.h"
     
    5555                @param object The object to store
    5656            */
    57             ObjectListBaseElement(OrxonoxClass* object) : object_(object), next_(0), prev_(0) {}
     57            ObjectListBaseElement(OrxonoxClass* objectBase) : next_(0), prev_(0), objectBase_(objectBase) {}
    5858
    59             OrxonoxClass* object_;              //!< The object
    6059            ObjectListBaseElement* next_;       //!< The next element in the list
    6160            ObjectListBaseElement* prev_;       //!< The previous element in the list
     61            OrxonoxClass* objectBase_;
     62    };
     63
     64
     65    // ###############################
     66    // ###    ObjectListElement    ###
     67    // ###############################
     68    //! The list-element that actually contains the object
     69    template <class T>
     70    class ObjectListElement : public ObjectListBaseElement
     71    {
     72        public:
     73            ObjectListElement(T* object) : ObjectListBaseElement(object), object_(object) {}
     74            T* object_;              //!< The object
    6275    };
    6376
     
    7992            ~ObjectListBase();
    8093
    81             ObjectListBaseElement* add(OrxonoxClass* object);
     94            ObjectListBaseElement* add(ObjectListBaseElement* element);
     95
     96            struct Export
     97            {
     98                Export(ObjectListBase* list, ObjectListBaseElement* element) : list_(list), element_(element) {}
     99                ObjectListBase* list_;
     100                ObjectListBaseElement* element_;
     101            };
    82102
    83103            /** @brief Returns a pointer to the first element in the list. @return The element */
    84             inline ObjectListBaseElement* begin() const { return this->first_; }
     104            inline Export begin() { return ObjectListBase::Export(this, this->first_); }
    85105            /** @brief Returns a pointer to the element after the last element in the list. @return The element */
    86             inline ObjectListBaseElement* end() const { return 0; }
     106            inline Export end() { return ObjectListBase::Export(this, 0); }
    87107            /** @brief Returns a pointer to the last element in the list. @return The element */
    88             inline ObjectListBaseElement* rbegin() const { return this->last_; }
     108            inline Export rbegin() { return ObjectListBase::Export(this, this->last_); }
    89109            /** @brief Returns a pointer to the element in front of the first element in the list. @return The element */
    90             inline ObjectListBaseElement* rend() const { return 0; }
     110            inline Export rend() { return ObjectListBase::Export(this, 0); }
    91111
    92             inline void registerIterator(IteratorBase* iterator)
    93                 { this->iterators_.insert(this->iterators_.end(), iterator); }
    94             inline void unregisterIterator(IteratorBase* iterator)
    95                 { this->iterators_.erase(iterator); }
    96             void notifyIterators(ObjectListBaseElement* element);
     112            inline std::list<void*>::iterator registerIterator(void* iterator) { return this->iterators_.insert(this->iterators_.begin(), iterator); }
     113            inline void unregisterIterator(const std::list<void*>::iterator& iterator) { this->iterators_.erase(iterator); }
     114            inline std::list<void*>::iterator registerObjectListIterator(void* iterator) { return this->objectListIterators_.insert(this->iterators_.begin(), iterator); }
     115            inline void unregisterObjectListIterator(const std::list<void*>::iterator& iterator) { this->objectListIterators_.erase(iterator); }
     116            void notifyIterators(OrxonoxClass* object) const;
    97117
    98118            inline Identifier* getIdentifier() const { return this->identifier_; }
    99119
    100120        private:
    101             Identifier* identifier_;             //!< The Iterator owning this list
    102             ObjectListBaseElement* first_;       //!< The first element in the list
    103             ObjectListBaseElement* last_;        //!< The last element in the list
    104             std::set<IteratorBase*> iterators_;  //!< A list of iterators pointing on an element in this list
     121            Identifier* identifier_;               //!< The Iterator owning this list
     122            ObjectListBaseElement* first_;         //!< The first element in the list
     123            ObjectListBaseElement* last_;          //!< The last element in the list
     124            std::list<void*> iterators_;           //!< A list of Iterators pointing on an element in this list
     125            std::list<void*> objectListIterators_; //!< A list of ObjectListIterators pointing on an element in this list
    105126    };
    106127}
  • code/branches/core3/src/core/Shell.cc

    r1586 r1591  
    6868
    6969        this->outputBuffer_.registerListener(this);
     70        OutputHandler::getOutStream().setOutputBuffer(this->outputBuffer_);
    7071
    7172        this->setConfigValues();
  • code/branches/core3/src/network/ConnectionManager.cc

    r1574 r1591  
    4444#include "core/CoreIncludes.h"
    4545#include "core/BaseObject.h"
     46#include "core/Iterator.h"
    4647#include "objects/SpaceShip.h"
    4748#include "util/Math.h"
     
    337338  bool ConnectionManager::removeShip(ClientInformation *client){
    338339    int id=client->getShipID();
    339     orxonox::Iterator<orxonox::SpaceShip> it;
     340    orxonox::ObjectList<orxonox::SpaceShip>::iterator it;
    340341    for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){
    341342      if(it->objectID!=id)
  • code/branches/core3/src/network/GameStateClient.cc

    r1574 r1591  
    3333#include "core/CoreIncludes.h"
    3434#include "core/BaseObject.h"
     35#include "core/Iterator.h"
    3536#include "Synchronisable.h"
    3637
     
    137138  * @return iterator pointing to the next object in the list
    138139  */
    139   void GameStateClient::removeObject(orxonox::Iterator<Synchronisable> &it) {
    140     orxonox::Iterator<Synchronisable> temp=it;
     140  void GameStateClient::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
     141    orxonox::ObjectList<Synchronisable>::iterator temp=it;
    141142    ++it;
    142143    delete  *temp;
     
    151152    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
    152153    // get the start of the Synchronisable list
    153     orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::begin();
     154    orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
    154155    syncData sync;
    155156    // loop as long as we have some data ;)
     
    222223    int tempsize=0;
    223224    // get the start of the Synchronisable list
    224     orxonox::Iterator<Synchronisable> it;
     225    orxonox::ObjectList<Synchronisable>::iterator it;
    225226    // struct for return value of Synchronisable::getData()
    226227    syncData sync;
  • code/branches/core3/src/network/GameStateClient.h

    r1505 r1591  
    4242
    4343#include <map>
    44 // 
     44//
    4545#include "NetworkPrereqs.h"
    4646#include "core/CorePrereqs.h"
     
    5858    GameStateClient();
    5959    ~GameStateClient();
    60    
     60
    6161    void addGameState(GameStateCompressed *gs);
    6262    int processGameState();
     
    7272    GameState *decode(GameState *old, GameStateCompressed *diff);
    7373    GameState *decode(GameStateCompressed *x);
    74     void removeObject(orxonox::Iterator<Synchronisable> &it);
     74    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
    7575    void printGameStateMap();
    7676    bool saveShipCache();
     
    8383    orxonox::SpaceShip *myShip_;
    8484    syncData shipCache_;
    85    
    86    
    87    
    88    
     85
     86
     87
     88
    8989  public:
    9090    //#### ADDED FOR TESTING PURPOSE ####
  • code/branches/core3/src/network/GameStateManager.cc

    r1574 r1591  
    4848#include "core/CoreIncludes.h"
    4949#include "core/BaseObject.h"
     50#include "core/Iterator.h"
    5051#include "ClientInformation.h"
    5152#include "Synchronisable.h"
     
    180181    int tempsize=0;
    181182    // get the start of the Synchronisable list
    182     orxonox::Iterator<Synchronisable> it;
     183    orxonox::ObjectList<Synchronisable>::iterator it;
    183184    // struct for return value of Synchronisable::getData()
    184185    syncData sync;
     
    246247    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
    247248    // get the start of the Synchronisable list
    248     orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::begin();
     249    orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
    249250    syncData sync;
    250251    /*ClientInformation *client = head_->findClient(clientID);
  • code/branches/core3/src/network/Server.cc

    r1574 r1591  
    5252#include "objects/SpaceShip.h"
    5353#include "core/ConsoleCommand.h"
     54#include "core/Iterator.h"
    5455
    5556namespace network
     
    400401
    401402    //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
    402     orxonox::Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
     403    orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
    403404    ClientInformation *client = clients->findClient(&event->peer->address);
    404405    if(!client)
     
    409410        continue;
    410411      }
    411       orxonox::Iterator<orxonox::SpaceShip> temp=it;
     412      orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it;
    412413      ++it;
    413414      delete  *temp;
  • code/branches/core3/src/network/Synchronisable.h

    r1534 r1591  
    8585    Synchronisable();
    8686  private:
    87     /*  bool removeObject(Iterator<Synchronisable> it);*/
     87    /*  bool removeObject(ObjectList<Synchronisable>::iterator it);*/
    8888
    8989    std::list<synchronisableVariable *> *syncList;
  • code/branches/core3/src/orxonox/GraphicsEngine.cc

    r1586 r1591  
    4747#include "core/CoreIncludes.h"
    4848#include "core/ConfigValueIncludes.h"
     49#include "core/Iterator.h"
    4950#include "core/CommandExecutor.h"
    5051#include "core/ConsoleCommand.h"
     
    100101
    101102    if (this->detailLevelParticle_ != old)
    102       for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
     103      for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    103104        it->detailLevelChanged(this->detailLevelParticle_);
    104105  }
  • code/branches/core3/src/orxonox/Orxonox.cc

    r1586 r1591  
    5454// core
    5555#include "core/ConfigFileManager.h"
     56#include "core/Iterator.h"
    5657#include "core/ConsoleCommand.h"
    5758#include "core/Loader.h"
     
    7576#include "GraphicsEngine.h"
    7677#include "Settings.h"
     78
    7779
    7880// FIXME: is this really file scope?
     
    169171    Orxonox::getSingleton()->timefactor_ = factor;
    170172
    171     for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
     173    for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    172174        it->setSpeedFactor(it->getSpeedFactor() * change);
    173175  }
     
    462464      Core::tick((float)evt.timeSinceLastFrame);
    463465      // Call those objects that need the real time
    464       for (Iterator<TickableReal> it = ObjectList<TickableReal>::begin(); it; ++it)
     466      for (ObjectList<TickableReal>::iterator it = ObjectList<TickableReal>::begin(); it; ++it)
    465467        it->tick((float)evt.timeSinceLastFrame);
    466468      // Call the scene objects
    467       for (Iterator<Tickable> it = ObjectList<Tickable>::begin(); it; ++it)
     469      for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    468470        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    469471      //AudioManager::tick();
  • code/branches/core3/src/orxonox/objects/NPC.cc

    r1574 r1591  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "core/Iterator.h"
    3334
    3435namespace orxonox {
     
    117118    int numberOfNeighbour = 0;  //number of observed neighbours
    118119    float distance = 0;  // distance to the actual element
    119     for(Iterator<WorldEntity> it = ObjectList<WorldEntity>::begin(); it; ++it) {  //go through all elements
     120    for(ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it; ++it) {  //go through all elements
    120121      distance = getDistance(*it);  //get distance between this and actual
    121122      if ((distance > 0) && (distance < SEPERATIONDISTANCE)) {  //do only if actual is inside detectionradius
     
    144145    //float distance = 0;
    145146    //go through all elements
    146     for(Iterator<NPC> it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
     147    for(ObjectList<NPC>::iterator it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
    147148      float distance = getDistance(*it);  //get distance between this and actual
    148149      if ((distance > 0) && (distance < ALIGNMENTDISTANCE)) {  //check if actual element is inside detectionradius
     
    164165    //float distance = 0;
    165166    //go through all elements
    166     for(Iterator<NPC> it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
     167    for(ObjectList<NPC>::iterator it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
    167168      float distance = getDistance(*it);  //get distance between this and actual
    168169      if ((distance > 0) && (distance < COHESIONDISTANCE)) {  //check if actual element is inside detectionradius
  • code/branches/core3/src/orxonox/objects/Projectile.cc

    r1584 r1591  
    3535#include "core/Executor.h"
    3636#include "core/ConfigValueIncludes.h"
     37#include "core/Iterator.h"
    3738#include "tools/ParticleInterface.h"
    3839
     
    8788
    8889        float radius;
    89         for (Iterator<Model> it = ObjectList<Model>::begin(); it; ++it)
     90        for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it)
    9091        {
    9192            if ((*it) != this->owner_)
  • code/branches/core3/src/orxonox/objects/SpaceShip.cc

    r1586 r1591  
    4141#include "core/CoreIncludes.h"
    4242#include "core/ConfigValueIncludes.h"
     43#include "core/Iterator.h"
    4344#include "core/input/InputManager.h"
    4445#include "core/XMLPort.h"
     
    7172
    7273    SpaceShip *SpaceShip::getLocalShip(){
    73       Iterator<SpaceShip> it;
     74      ObjectList<SpaceShip>::iterator it;
    7475      for(it = ObjectList<SpaceShip>::begin(); it; ++it){
    7576        if( (it)->myShip_ )
  • code/branches/core3/src/orxonox/objects/SpaceShipAI.cc

    r1566 r1591  
    7272    SpaceShipAI::~SpaceShipAI()
    7373    {
    74         for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; ++it)
     74        for (ObjectList<SpaceShipAI>::iterator it = ObjectList<SpaceShipAI>::begin(); it; ++it)
    7575            it->shipDied(this);
    7676    }
     
    111111    {
    112112        int i = 0;
    113         for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; )
     113        for (ObjectList<SpaceShipAI>::iterator it = ObjectList<SpaceShipAI>::begin(); it; )
    114114        {
    115115            (it++)->kill();
     
    259259        this->forgetTarget();
    260260
    261         for (Iterator<SpaceShip> it = ObjectList<SpaceShip>::begin(); it; ++it)
     261        for (ObjectList<SpaceShip>::iterator it = ObjectList<SpaceShip>::begin(); it; ++it)
    262262        {
    263263            if (it->getTeamNr() != this->getTeamNr())
Note: See TracChangeset for help on using the changeset viewer.