Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 9, 2008, 4:25:52 AM (16 years ago)
Author:
landauf
Message:

merged core3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/MetaObjectList.h

    r1543 r1747  
    4141#include "CorePrereqs.h"
    4242
    43 #include "ObjectList.h"
    44 #include "Identifier.h"
    45 #include "Debug.h"
    46 
    4743namespace orxonox
    4844{
    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 
    5945    // ###############################
    6046    // ###  MetaObjectListElement  ###
    6147    // ###############################
    6248    //! The list-element of the MetaObjectList
    63     template <class T>
    64     class MetaObjectListElement : public BaseMetaObjectListElement
     49    class _CoreExport MetaObjectListElement
    6550    {
    6651        public:
    67             MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element);
    68             virtual ~MetaObjectListElement();
     52            /**
     53                @brief Constructor: Creates the list-element with given list and element.
     54            */
     55            MetaObjectListElement(ObjectListBase* list, ObjectListBaseElement* element) : next_(0), element_(element), list_(list) {}
     56            ~MetaObjectListElement();
    6957
    70             ObjectListElement<T>* element_;         //!< The list element, containing the object
    71             ObjectList<T>* list_;                   //!< The list, containing the element
     58            MetaObjectListElement* next_;       //!< The next Element in the list
     59            ObjectListBaseElement* element_;    //!< The list element, containing the object
     60            ObjectListBase* list_;              //!< The list, containing the element
    7261    };
    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     }
    10662
    10763
     
    10965    // ###     MetaObjectList      ###
    11066    // ###############################
    111     //!  The MetaObjectList contains ObjectListElements and their ObjectLists.
     67    //!  The MetaObjectList contains ObjectListBaseElements and their ObjectListBases.
    11268    /**
    11369        The MetaObjectList is a single-linked list, containing all list-elements and their
     
    12076            MetaObjectList();
    12177            ~MetaObjectList();
    122             template <class T>
    123             void add(ObjectList<T>* list, ObjectListElement<T>* element);
     78            void add(ObjectListBase* list, ObjectListBaseElement* element);
    12479
    125             BaseMetaObjectListElement* first_;      //!< The first element in the list
     80            MetaObjectListElement* first_;      //!< The first element in the list
    12681    };
    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     }
    14082}
    14183
Note: See TracChangeset for help on using the changeset viewer.