Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2008, 4:35:38 AM (16 years ago)
Author:
landauf
Message:

big change in ObjectList: separated the class into a non-template base and a template wrapper for the base. this also changes the Iterator, there is now a non-template IteratorBase. this brings much more flexibility, like iterating through all objects of a given identifier without knowing the type. however this needs a dynamic_cast, which isn't quite optimal, but I think there are much worser things than that out there. ;)

there isn't much you have to know about this, except there is no more ObjectList<myClass>::start() function but a ObjectList<myClass>::begin() to be more STLish. another thing: ObjectList<myClass>::end() points now to the element _after_ the last element, so it's possible to iterate in a for-loop until (it != ObjectList<myClass>::end()). the reason is the same as above. however, (it) as a boolean still works perfectly fine.

Location:
code/branches/core3/src/core
Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/CMakeLists.txt

    r1555 r1574  
    55  Error.cc
    66  Language.cc
     7  ObjectListBase.cc
    78  OrxonoxClass.cc
    89  OutputBuffer.cc
  • code/branches/core3/src/core/ClassTreeMask.h

    r1505 r1574  
    7878namespace orxonox
    7979{
    80     // ###############################
    81     // ###    ClassTreeMaskNode    ###
    82     // ###############################
     80    // ###################################
     81    // ###      ClassTreeMaskNode      ###
     82    // ###################################
    8383    //! The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask.
    8484    /**
     
    116116
    117117
    118     // ###############################
    119     // ###  ClassTreeMaskIterator  ###
    120     // ###############################
     118    // ###################################
     119    // ###    ClassTreeMaskIterator    ###
     120    // ###################################
    121121    //! The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask, containing the rules.
    122122    /**
     
    146146
    147147
    148     // ###############################
    149     // ###      ClassTreeMask      ###
    150     // ###############################
     148    // ###################################
     149    // ###        ClassTreeMask        ###
     150    // ###################################
    151151    //! The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not.
    152152    /**
     
    214214            ClassTreeMaskNode* root_;   //!< The root-node of the internal rule-tree, usually BaseObject
    215215    };
     216
     217
     218    // ###################################
     219    // ### ClassTreeMaskObjectIterator ###
     220    // ###################################
     221    //! ...
     222    /**
     223        ...
     224    */
     225    class _CoreExport ClassTreeMaskObjectIterator
     226    {
     227    };
    216228}
    217229
  • code/branches/core3/src/core/CorePrereqs.h

    r1543 r1574  
    125125  template <class T>
    126126  class Iterator;
     127  class IteratorBase;
    127128  class Language;
    128129  class LanguageEntry;
     
    130131  class Loader;
    131132  class MetaObjectList;
    132   template <class T>
    133133  class MetaObjectListElement;
    134134  class Namespace;
     
    136136  template <class T>
    137137  class ObjectList;
    138   template <class T>
    139   class ObjectListElement;
     138  class ObjectListBase;
     139  class ObjectListBaseElement;
    140140  class OrxonoxClass;
    141141  class OutputBuffer;
  • code/branches/core3/src/core/Identifier.cc

    r1543 r1574  
    3939#include "ConsoleCommand.h"
    4040#include "CommandExecutor.h"
     41#include "MetaObjectList.h"
     42#include "ObjectList.h"
     43#include "OrxonoxClass.h"
    4144
    4245namespace orxonox
     
    5255    Identifier::Identifier()
    5356    {
     57        this->objects_ = new ObjectListBase(this);
     58
    5459        this->bCreatedOneObject_ = false;
    5560        this->factory_ = 0;
     
    174179
    175180    /**
     181        @brief Adds an object of the given type to the ObjectList.
     182        @param object The object to add
     183    */
     184    void Identifier::addObject(OrxonoxClass* object)
     185    {
     186        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
     187        object->getMetaList().add(this->objects_, this->objects_->add(object));
     188    }
     189
     190    /**
    176191        @brief Returns true, if the Identifier is at least of the given type.
    177192        @param identifier The identifier to compare with
  • code/branches/core3/src/core/Identifier.h

    r1543 r1574  
    6060#include <utility>
    6161
    62 #include "ObjectList.h"
    6362#include "Debug.h"
    6463#include "Iterator.h"
    65 #include "MetaObjectList.h"
    6664#include "util/String.h"
    6765
     
    108106            bool isDirectParentOf(const Identifier* identifier) const;
    109107
    110             virtual const ObjectList<BaseObject>* getObjectList() const = 0;
    111 
    112             virtual void updateConfigValues() const = 0;
     108            void addObject(OrxonoxClass* object);
     109
     110            /** @brief Returns the list of all existing objects of this class. @return The list */
     111            inline ObjectListBase* getObjects() const
     112                { return this->objects_; }
    113113
    114114            /** @brief Returns the name of the class the Identifier belongs to. @return The name */
    115115            inline const std::string& getName() const { return this->name_; }
    116116
     117            virtual void updateConfigValues() const = 0;
    117118
    118119            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
     
    263264            std::string name_;                                             //!< The name of the class the Identifier belongs to
    264265
     266            ObjectListBase* objects_;                                      //!< The list of all objects of this class
    265267            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
    266268            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
     
    297299        public:
    298300            ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass);
    299             void addObject(T* object);
    300301            void setName(const std::string& name);
    301             /** @brief Returns the list of all existing objects of this class. @return The list */
    302             inline ObjectList<T>* getObjects() const { return this->objects_; }
    303             /** @brief Returns a list of all existing objects of this class. @return The list */
    304             inline ObjectList<BaseObject>* getObjectList() const { return (ObjectList<BaseObject>*)this->objects_; }
    305302
    306303            void updateConfigValues() const;
     
    319316            ~ClassIdentifier() {}                                       // don't delete
    320317
    321             ObjectList<T>* objects_;                                                                    //!< The ObjectList, containing all objects of type T
    322318            bool bSetName_;                                                                             //!< True if the name is set
    323319            std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_;              //!< All loadable parameters
     
    336332    ClassIdentifier<T>::ClassIdentifier()
    337333    {
    338 //        this->objects_ = ObjectList<T>::getList();
    339         this->objects_ = new ObjectList<T>();
    340334        this->bSetName_ = false;
    341335    }
     
    408402
    409403    /**
    410         @brief Adds an object of the given type to the ObjectList.
    411         @param object The object to add
    412     */
    413     template <class T>
    414     void ClassIdentifier<T>::addObject(T* object)
    415     {
    416         COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    417         object->getMetaList().add(this->objects_, this->objects_->add(object));
    418     }
    419 
    420     /**
    421404        @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function.
    422405    */
     
    424407    void ClassIdentifier<T>::updateConfigValues() const
    425408    {
    426         for (Iterator<T> it = this->objects_->start(); it; ++it)
    427             ((T*)*it)->setConfigValues();
     409        for (Iterator<T> it = this->objects_->begin(); it; ++it)
     410            (*it)->setConfigValues();
    428411    }
    429412
  • code/branches/core3/src/core/Iterator.h

    r1543 r1574  
    3535
    3636    Usage:
    37     for (Iterator<class> it = ObjectList<class>::start(); it != 0; ++it)
     37    for (Iterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it)
    3838    {
    3939        it->someFunction(...);
    40         class* myObject = *it;
     40        myClass* myObject = *it;
    4141    }
    42 
    43     Warning: Don't delete objects directly through the iterator.
    4442*/
    4543
     
    4947#include "CorePrereqs.h"
    5048
    51 #include "ObjectList.h"
     49#include "IteratorBase.h"
    5250
    5351namespace orxonox
    5452{
    55     //! The iterator allows to iterate through an ObjectList of a given class.
     53    //! The Iterator allows to iterate through the ObjectList of a given class.
    5654    template <class T>
    57     class Iterator
     55    class Iterator : public IteratorBase
    5856    {
    5957        public:
     
    6159                @brief Constructor: Sets the element, whereon the iterator points, to zero.
    6260            */
    63             Iterator()
     61            inline Iterator()
    6462            {
    65                 this->element_ = 0;
    6663                ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
    6764            }
     
    7168                @param element The element to start with
    7269            */
    73             Iterator(ObjectListElement<T>* element)
     70            inline Iterator(ObjectListBaseElement* element) : IteratorBase((ObjectListBaseElement*)element)
    7471            {
    75                 this->element_ = element;
    7672                ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
    7773            }
     
    8076                @brief Unregisters the Iterator from the ObjectList.
    8177            */
    82             ~Iterator()
     78            inline ~Iterator()
    8379            {
    8480                ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterIterator(this);
    85             }
    86 
    87             /**
    88                 @brief Assigns an element to the iterator.
    89                 @param element The element
    90             */
    91             Iterator<T> operator=(ObjectListElement<T>* element)
    92             {
    93                 this->element_ = element;
    9481            }
    9582
     
    9885                @return The Iterator itself
    9986            */
    100             Iterator<T> operator++()
     87            inline Iterator<T> operator++()
    10188            {
    102                 if (this->element_)
    103                     this->element_ = this->element_->next_;
     89                IteratorBase::operator++();
    10490                return *this;
    10591            }
     
    10995                @return The Iterator itself
    11096            */
    111             Iterator<T> operator++(int i)
     97            inline Iterator<T> operator++(int i)
    11298            {
    11399                Iterator<T> copy = *this;
    114                 if (this->element_)
    115                     this->element_ = this->element_->next_;
     100                IteratorBase::operator++();
    116101                return copy;
    117102            }
     
    121106                @return The Iterator itself
    122107            */
    123             Iterator<T> operator--()
     108            inline Iterator<T> operator--()
    124109            {
    125                 if (this->element_)
    126                     this->element_ = this->element_->prev_;
     110                IteratorBase::operator--();
    127111                return *this;
    128112            }
     
    132116                @return The Iterator itself
    133117            */
    134             Iterator<T> operator--(int i)
     118            inline Iterator<T> operator--(int i)
    135119            {
    136120                Iterator<T> copy = *this;
    137                 if (this->element_)
    138                     this->element_ = this->element_->prev_;
     121                IteratorBase::operator--();
    139122                return copy;
    140123            }
     
    144127                @return The object the Iterator points at
    145128            */
    146             T* operator*()
     129            inline T* operator*()
    147130            {
    148                 if (this->element_)
    149                     return this->element_->object_;
    150                 else
    151                     return 0;
     131                return dynamic_cast<T*>(IteratorBase::operator*());
    152132            }
    153133
     
    156136                @return The object the Iterator points at
    157137            */
    158             T* operator->() const
     138            inline T* operator->() const
    159139            {
    160                 if (this->element_)
    161                     return this->element_->object_;
    162                 else
    163                     return 0;
    164 
     140                return dynamic_cast<T*>(IteratorBase::operator->());
    165141            }
    166142
    167143            /**
    168                 @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
    169                 @return True if the iterator points to an existing object.
     144                @brief Overloading of the == operator to compare with another Iterator.
     145                @param compare The other Iterator
     146                @return True if the iterators point to the same element
    170147            */
    171             operator bool()
     148            inline bool operator==(const Iterator<T>& compare)
    172149            {
    173                 return (this->element_ != 0);
     150                return (this->element_ == compare.element_);
    174151            }
    175152
    176153            /**
    177                 @brief Overloading of the (it != int) operator: Used for (it != 0) instead of typecast-operator to bool.
    178                 @param compare The integer (must be zero, everything else makes no sense).
    179                 @return True if the iterator points to an existing object.
     154                @brief Overloading of the != operator to compare with another Iterator.
     155                @param compare The other Iterator
     156                @return True if the iterators point to different elements
    180157            */
    181             bool operator!=(ObjectListElement<T>* compare)
     158            inline bool operator!=(const Iterator<T>& compare)
    182159            {
    183                 return (this->element_ != compare);
     160                return (this->element_ != compare.element_);
    184161            }
    185 
    186         private:
    187             ObjectListElement<T>* element_;     //!< The element the Iterator points at
    188162    };
    189163}
    190164
     165// Include ObjectList.h so the user only has to include one file: Iterator.h
     166#include "ObjectList.h"
     167
    191168#endif /* _Iterator_H__ */
  • code/branches/core3/src/core/Loader.cc

    r1505 r1574  
    3232#include "Identifier.h"
    3333#include "Iterator.h"
     34#include "ObjectList.h"
    3435#include "Debug.h"
    3536#include "CoreIncludes.h"
     
    9192    void Loader::unload(const ClassTreeMask& mask)
    9293    {
    93         for (Iterator<BaseObject> it = ObjectList<BaseObject>::begin(); it; )
     94        for (Iterator<BaseObject> it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); )
    9495        {
    9596            if (mask.isIncluded(it->getIdentifier()))
  • code/branches/core3/src/core/MetaObjectList.cc

    r1505 r1574  
    3333
    3434#include "MetaObjectList.h"
     35#include "Debug.h"
    3536
    3637namespace orxonox
    3738{
     39    // ###############################
     40    // ###  MetaObjectListElement  ###
     41    // ###############################
     42    /**
     43        @brief Destructor: Removes the ObjectListBaseElement from the ObjectListBase by linking next_ and prev_ of the ObjectListBaseElement.
     44    */
     45    MetaObjectListElement::~MetaObjectListElement()
     46    {
     47        COUT(5) << "*** MetaObjectList: Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << std::endl;
     48        this->list_->notifyIterators(this->element_);
     49
     50        if (this->element_->next_)
     51            this->element_->next_->prev_ = this->element_->prev_;
     52        else
     53            this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
     54
     55        if (this->element_->prev_)
     56            this->element_->prev_->next_ = this->element_->next_;
     57        else
     58            this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
     59
     60        delete this->element_;
     61    }
     62
     63
     64    // ###############################
     65    // ###     MetaObjectList      ###
     66    // ###############################
    3867    /**
    3968        @brief Constructor: Sets first_ to zero.
     
    4978    MetaObjectList::~MetaObjectList()
    5079    {
    51         BaseMetaObjectListElement* temp;
     80        MetaObjectListElement* temp;
    5281        while (this->first_)
    5382        {
     
    5786        }
    5887    }
     88
     89    /**
     90        @brief Adds an ObjectList and an element of that list to the MetaObjectList.
     91        @param list The ObjectList wherein the element is
     92        @param element The element wherein the object is
     93    */
     94    void MetaObjectList::add(ObjectListBase* list, ObjectListBaseElement* element)
     95    {
     96        MetaObjectListElement* temp = this->first_;
     97        this->first_ = new MetaObjectListElement(list, element);
     98        this->first_->next_ = temp;
     99    }
    59100}
  • code/branches/core3/src/core/MetaObjectList.h

    r1543 r1574  
    4141#include "CorePrereqs.h"
    4242
    43 #include "ObjectList.h"
     43#include "ObjectListBase.h"
    4444#include "Identifier.h"
    45 #include "Debug.h"
    4645
    4746namespace orxonox
    4847{
    49     //! Base-class of MetaObjectListElement, because those is a template
    50     class BaseMetaObjectListElement
    51     {
    52         public:
    53             /** @brief Default destructor */
    54             virtual ~BaseMetaObjectListElement() {};
    55 
    56             BaseMetaObjectListElement* next_;       //!< The next Element in the list
    57     };
    58 
    5948    // ###############################
    6049    // ###  MetaObjectListElement  ###
    6150    // ###############################
    6251    //! The list-element of the MetaObjectList
    63     template <class T>
    64     class MetaObjectListElement : public BaseMetaObjectListElement
     52    class _CoreExport MetaObjectListElement
    6553    {
    6654        public:
    67             MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element);
    68             virtual ~MetaObjectListElement();
     55            /**
     56                @brief Constructor: Creates the list-element with given list and element.
     57            */
     58            MetaObjectListElement(ObjectListBase* list, ObjectListBaseElement* element) : next_(0), element_(element), list_(list) {}
     59            ~MetaObjectListElement();
    6960
    70             ObjectListElement<T>* element_;         //!< The list element, containing the object
    71             ObjectList<T>* list_;                   //!< The list, containing the element
     61            MetaObjectListElement* next_;       //!< The next Element in the list
     62            ObjectListBaseElement* element_;    //!< The list element, containing the object
     63            ObjectListBase* list_;              //!< The list, containing the element
    7264    };
    73 
    74     /**
    75         @brief Constructor: Creates the list-element with given list and element.
    76     */
    77     template <class T>
    78     MetaObjectListElement<T>::MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element)
    79     {
    80         this->element_ = element;
    81         this->list_ = list;
    82         this->next_ = 0;
    83     }
    84 
    85     /**
    86         @brief Destructor: Removes the ObjectListElement from the ObjectList by linking next_ and prev_ of the ObjectListElement.
    87     */
    88     template <class T>
    89     MetaObjectListElement<T>::~MetaObjectListElement()
    90     {
    91         COUT(5) << "*** MetaObjectList: Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list." << std::endl;
    92         this->list_->notifyIterators(this->element_);
    93 
    94         if (this->element_->next_)
    95             this->element_->next_->prev_ = this->element_->prev_;
    96         else
    97             this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
    98 
    99         if (this->element_->prev_)
    100             this->element_->prev_->next_ = this->element_->next_;
    101         else
    102             this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
    103 
    104         delete this->element_;
    105     }
    10665
    10766
     
    10968    // ###     MetaObjectList      ###
    11069    // ###############################
    111     //!  The MetaObjectList contains ObjectListElements and their ObjectLists.
     70    //!  The MetaObjectList contains ObjectListBaseElements and their ObjectListBases.
    11271    /**
    11372        The MetaObjectList is a single-linked list, containing all list-elements and their
     
    12079            MetaObjectList();
    12180            ~MetaObjectList();
    122             template <class T>
    123             void add(ObjectList<T>* list, ObjectListElement<T>* element);
     81            void add(ObjectListBase* list, ObjectListBaseElement* element);
    12482
    125             BaseMetaObjectListElement* first_;      //!< The first element in the list
     83            MetaObjectListElement* first_;      //!< The first element in the list
    12684    };
    127 
    128     /**
    129         @brief Adds an ObjectList and an element of that list to the MetaObjectList.
    130         @param list The ObjectList wherein the element is
    131         @param element The element wherein the object is
    132     */
    133     template <class T>
    134     void MetaObjectList::add(ObjectList<T>* list, ObjectListElement<T>* element)
    135     {
    136         BaseMetaObjectListElement* temp = this->first_;
    137         this->first_ = new MetaObjectListElement<T>(list, element);
    138         this->first_->next_ = temp;
    139     }
    14085}
    14186
  • code/branches/core3/src/core/ObjectList.h

    r1543 r1574  
    3131    @brief Definition and implementation of the ObjectList class.
    3232
    33     The ObjectList is a double-linked list, used by Identifiers to store all objects of a given class.
    34     Newly created objects are added through the RegisterObject-macro in its constructor.
     33    The ObjectList is a wrapper of an ObjectListBase of a given class.
    3534    Use Iterator<class> to iterate through all objects of the class.
    3635*/
     
    3938#define _ObjectList_H__
    4039
    41 #include <set>
    42 
    4340#include "CorePrereqs.h"
    4441
     42#include "Identifier.h"
    4543#include "Iterator.h"
    46 #include "Identifier.h"
    4744
    4845namespace orxonox
    4946{
    5047    // ###############################
    51     // ###    ObjectListElement    ###
    52     // ###############################
    53     //! The list-element of the ObjectList
    54     template <class T>
    55     class ObjectListElement
    56     {
    57         public:
    58             ObjectListElement(T* object);
    59 
    60             T* object_;                     //!< The object
    61             ObjectListElement* next_;       //!< The next element in the list
    62             ObjectListElement* prev_;       //!< The previous element in the list
    63     };
    64 
    65     /**
    66         @brief Constructor: Creates the list-element with an object.
    67         @param object The object to store
    68     */
    69     template <class T>
    70     ObjectListElement<T>::ObjectListElement(T* object)
    71     {
    72         this->object_ = object;
    73         this->next_ = 0;
    74         this->prev_ = 0;
    75     }
    76 
    77 
    78     // ###############################
    7948    // ###       ObjectList        ###
    8049    // ###############################
    81     //! The ObjectList contains all objects of a given class.
     50    //! The ObjectList contains all objects of the given class.
    8251    /**
    83         The ObjectList is used by Identifiers to store all objects of a given class.
     52        Wraps the ObjectListBase of the corresponding Identifier.
    8453        Use Iterator<class> to iterate through all objects in the list.
    8554    */
     
    8857    {
    8958        public:
    90             ObjectList();
    91             ~ObjectList();
     59            /** @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()); }
    9262
    93             ObjectListElement<T>* add(T* object);
     63            /** @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()); }
    9466
    95             /** @brief Returns the first element in the list. @return The first element */
    96             inline static Iterator<T> start()
    97                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->first_); }
     67            /** @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()); }
    9870
    99             /** @brief Returns the first element in the list. @return The first element */
    100             inline static Iterator<T> begin()
    101                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->first_); }
    102 
    103             /** @brief Returns the last element in the list. @return The last element */
    104             inline static Iterator<T> end()
    105                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->last_); }
    106 
    107             inline void registerIterator(Iterator<T>* iterator)
    108                 { this->iterators_.insert(this->iterators_.end(), (void*)iterator); }
    109             inline void unregisterIterator(Iterator<T>* iterator)
    110                 { this->iterators_.erase((void*)iterator); }
    111             void notifyIterators(ObjectListElement<T>* element);
    112 
    113             ObjectListElement<T>* first_;       //!< The first element in the list
    114             ObjectListElement<T>* last_;        //!< The last element in the list
    115 
    116         private:
    117             std::set<void*> iterators_;  //!< A list of iterators pointing on an element in this list
     71            /** @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()); }
    11874    };
    119 
    120     /**
    121         @brief Constructor: Sets default values.
    122     */
    123     template <class T>
    124     ObjectList<T>::ObjectList()
    125     {
    126         this->first_ = 0;
    127         this->last_ = 0;
    128     }
    129 
    130     /**
    131         @brief Destructor: Deletes all list-elements, but NOT THE OBJECTS.
    132     */
    133     template <class T>
    134     ObjectList<T>::~ObjectList()
    135     {
    136         ObjectListElement<T>* temp;
    137         while (this->first_)
    138         {
    139             temp = this->first_->next_;
    140             delete this->first_;
    141             this->first_ = temp;
    142         }
    143     }
    144 
    145     /**
    146         @brief Increases all Iterators that currently point on the given element (because it gets removed).
    147         @param element The element that gets removed
    148     */
    149     template <class T>
    150     void ObjectList<T>::notifyIterators(ObjectListElement<T>* element)
    151     {
    152         for (std::set<void*>::iterator it = this->iterators_.begin(); it != this->iterators_.end(); ++it)
    153             if ((*(*((Iterator<T>*)(*it)))) == element->object_)
    154                 ++(*((Iterator<T>*)(*it)));
    155     }
    156 
    157     /**
    158         @brief Adds a new object to the end of the list.
    159         @param object The object to add
    160         @return The pointer to the new ObjectListElement, needed by the MetaObjectList of the added object
    161     */
    162     template <class T>
    163     ObjectListElement<T>* ObjectList<T>::add(T* object)
    164     {
    165         if (!this->last_)
    166         {
    167             // If the list is empty
    168             this->last_ = new ObjectListElement<T>(object);
    169             this->first_ = this->last_; // There's only one object in the list now
    170         }
    171         else
    172         {
    173             // If the list isn't empty
    174             ObjectListElement<T>* temp = this->last_;
    175             this->last_ = new ObjectListElement<T>(object);
    176             this->last_->prev_ = temp;
    177             temp->next_ = this->last_;
    178         }
    179 
    180         return this->last_;
    181     }
    18275}
    18376
  • code/branches/core3/src/core/OrxonoxClass.cc

    r1505 r1574  
    3939{
    4040    /** @brief Constructor: Sets the default values. */
    41     OrxonoxClass::OrxonoxClass() :
    42       identifier_(0),
    43       parents_(0)
     41    OrxonoxClass::OrxonoxClass()
    4442    {
     43        this->identifier_ = 0;
     44        this->parents_ = 0;
    4545        this->metaList_ = new MetaObjectList();
    4646
Note: See TracChangeset for help on using the changeset viewer.