Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9597 for code


Ignore:
Timestamp:
Mar 29, 2013, 11:44:22 AM (12 years ago)
Author:
landauf
Message:

removed MetaObjectList. replaced it by std::vector because object list elements can now remove themselves from their lists.

Location:
code/branches/core6/src/libraries/core
Files:
2 deleted
7 edited

Legend:

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

    r9585 r9597  
    167167    class MemoryArchive;
    168168    class MemoryArchiveFactory;
    169     class MetaObjectList;
    170     class MetaObjectListElement;
    171169    class Namespace;
    172170    class NamespaceNode;
  • code/branches/core6/src/libraries/core/class/Identifier.h

    r9593 r9597  
    9090
    9191#include "util/Output.h"
    92 #include "core/object/MetaObjectList.h"
    9392#include "core/object/ObjectList.h"
    9493#include "core/object/ObjectListBase.h"
     
    428427    {
    429428        orxout(verbose, context::object_list) << "Added object to " << this->getName() << "-list." << endl;
    430         object->metaList_->add(this->objects_, this->objects_->add(object));
     429        object->elements_.push_back(this->objects_->add(object));
    431430    }
    432431
  • code/branches/core6/src/libraries/core/object/CMakeLists.txt

    r9591 r9597  
    33  Destroyable.cc
    44  Listable.cc
    5   MetaObjectList.cc
    65  ObjectListBase.cc
    76)
  • code/branches/core6/src/libraries/core/object/Listable.cc

    r9572 r9597  
    3333
    3434#include "Listable.h"
    35 
    36 #include "core/object/MetaObjectList.h"
     35#include "ObjectListBase.h"
    3736
    3837namespace orxonox
    3938{
    4039    /**
    41         @brief Constructor: creates the meta-object-list.
     40        @brief Constructor: Allocates space in the element list.
    4241    */
    4342    Listable::Listable()
    4443    {
    45         this->metaList_ = new MetaObjectList();
     44        this->elements_.reserve(6);
    4645    }
    4746
     
    5958    void Listable::unregisterObject()
    6059    {
    61         if (this->metaList_)
    62             delete this->metaList_;
    63         this->metaList_ = 0;
     60        for (size_t i = 0; i < this->elements_.size(); ++i)
     61            delete this->elements_[i];
     62        this->elements_.clear();
    6463    }
    6564}
  • code/branches/core6/src/libraries/core/object/Listable.h

    r9572 r9597  
    3737
    3838#include "core/CorePrereqs.h"
     39
     40#include <vector>
     41
    3942#include "core/class/Identifiable.h"
    4043
     
    4245{
    4346    /**
    44         @brief Listable stores the MetaObjectList which is used when storing instances in object lists.
     47        @brief Listable stores the entries of all object lists pointing to this instance.
    4548    */
    4649    class _CoreExport Listable : virtual public Identifiable
     
    5659
    5760        private:
    58             MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
     61            std::vector<ObjectListBaseElement*> elements_; //!< The corresponding ObjectListElements in all object lists the object is registered in
    5962    };
    6063}
  • code/branches/core6/src/libraries/core/object/ObjectListBase.cc

    r9596 r9597  
    8484        @brief Adds a new object to the end of the list.
    8585        @param element The element to add
    86         @return The pointer to the new ObjectListBaseElement, needed by the MetaObjectList of the added object
    8786    */
    88     ObjectListBaseElement* ObjectListBase::addElement(ObjectListBaseElement* element)
     87    void ObjectListBase::addElement(ObjectListBaseElement* element)
    8988    {
    9089        if (!this->last_)
     
    102101            temp->next_ = this->last_;
    103102        }
    104 
    105         return this->last_;
    106103    }
    107104
     105    /**
     106     * @brief Removes the element from the list
     107     */
    108108    void ObjectListBase::removeElement(ObjectListBaseElement* element)
    109109    {
  • code/branches/core6/src/libraries/core/object/ObjectListBase.h

    r9596 r9597  
    101101            template <class T>
    102102            inline ObjectListBaseElement* add(T* object)
    103                 { return this->addElement(new ObjectListElement<T>(object, this)); }
     103            {
     104                ObjectListBaseElement* element = new ObjectListElement<T>(object, this);
     105                this->addElement(element);
     106                return element;
     107            }
    104108
    105             ObjectListBaseElement* addElement(ObjectListBaseElement* element);
     109            void addElement(ObjectListBaseElement* element);
    106110            void removeElement(ObjectListBaseElement* element);
    107111
Note: See TracChangeset for help on using the changeset viewer.