Changeset 1747 for code/trunk/src/core/MetaObjectList.h
- Timestamp:
- Sep 9, 2008, 4:25:52 AM (17 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core3 (added) merged: 1573-1574,1583-1586,1591-1594,1596-1597,1603,1606-1607,1610-1611,1655,1658,1676-1679,1681-1685,1687,1716-1723,1725-1729,1736
- Property svn:mergeinfo changed
-
code/trunk/src/core/MetaObjectList.h
r1543 r1747 41 41 #include "CorePrereqs.h" 42 42 43 #include "ObjectList.h"44 #include "Identifier.h"45 #include "Debug.h"46 47 43 namespace orxonox 48 44 { 49 //! Base-class of MetaObjectListElement, because those is a template50 class BaseMetaObjectListElement51 {52 public:53 /** @brief Default destructor */54 virtual ~BaseMetaObjectListElement() {};55 56 BaseMetaObjectListElement* next_; //!< The next Element in the list57 };58 59 45 // ############################### 60 46 // ### MetaObjectListElement ### 61 47 // ############################### 62 48 //! The list-element of the MetaObjectList 63 template <class T> 64 class MetaObjectListElement : public BaseMetaObjectListElement 49 class _CoreExport MetaObjectListElement 65 50 { 66 51 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(); 69 57 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 72 61 }; 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 else97 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 list98 99 if (this->element_->prev_)100 this->element_->prev_->next_ = this->element_->next_;101 else102 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 list103 104 delete this->element_;105 }106 62 107 63 … … 109 65 // ### MetaObjectList ### 110 66 // ############################### 111 //! The MetaObjectList contains ObjectList Elements and their ObjectLists.67 //! The MetaObjectList contains ObjectListBaseElements and their ObjectListBases. 112 68 /** 113 69 The MetaObjectList is a single-linked list, containing all list-elements and their … … 120 76 MetaObjectList(); 121 77 ~MetaObjectList(); 122 template <class T> 123 void add(ObjectList<T>* list, ObjectListElement<T>* element); 78 void add(ObjectListBase* list, ObjectListBaseElement* element); 124 79 125 BaseMetaObjectListElement* first_; //!< The first element in the list80 MetaObjectListElement* first_; //!< The first element in the list 126 81 }; 127 128 /**129 @brief Adds an ObjectList and an element of that list to the MetaObjectList.130 @param list The ObjectList wherein the element is131 @param element The element wherein the object is132 */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 }140 82 } 141 83
Note: See TracChangeset
for help on using the changeset viewer.