Changeset 1574 for code/branches/core3/src/core/MetaObjectList.h
- Timestamp:
- Jun 9, 2008, 4:35:38 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/core/MetaObjectList.h
r1543 r1574 41 41 #include "CorePrereqs.h" 42 42 43 #include "ObjectList .h"43 #include "ObjectListBase.h" 44 44 #include "Identifier.h" 45 #include "Debug.h"46 45 47 46 namespace orxonox 48 47 { 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 48 // ############################### 60 49 // ### MetaObjectListElement ### 61 50 // ############################### 62 51 //! The list-element of the MetaObjectList 63 template <class T> 64 class MetaObjectListElement : public BaseMetaObjectListElement 52 class _CoreExport MetaObjectListElement 65 53 { 66 54 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(); 69 60 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 72 64 }; 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 65 107 66 … … 109 68 // ### MetaObjectList ### 110 69 // ############################### 111 //! The MetaObjectList contains ObjectList Elements and their ObjectLists.70 //! The MetaObjectList contains ObjectListBaseElements and their ObjectListBases. 112 71 /** 113 72 The MetaObjectList is a single-linked list, containing all list-elements and their … … 120 79 MetaObjectList(); 121 80 ~MetaObjectList(); 122 template <class T> 123 void add(ObjectList<T>* list, ObjectListElement<T>* element); 81 void add(ObjectListBase* list, ObjectListBaseElement* element); 124 82 125 BaseMetaObjectListElement* first_; //!< The first element in the list83 MetaObjectListElement* first_; //!< The first element in the list 126 84 }; 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 85 } 141 86
Note: See TracChangeset
for help on using the changeset viewer.