Changeset 1591 for code/branches/core3/src/core/ObjectListBase.h
- Timestamp:
- Jun 12, 2008, 2:00:15 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/core/ObjectListBase.h
r1574 r1591 38 38 #define _ObjectListBase_H__ 39 39 40 #include < set>40 #include <list> 41 41 42 42 #include "CorePrereqs.h" … … 55 55 @param object The object to store 56 56 */ 57 ObjectListBaseElement(OrxonoxClass* object ) : object_(object), next_(0), prev_(0) {}57 ObjectListBaseElement(OrxonoxClass* objectBase) : next_(0), prev_(0), objectBase_(objectBase) {} 58 58 59 OrxonoxClass* object_; //!< The object60 59 ObjectListBaseElement* next_; //!< The next element in the list 61 60 ObjectListBaseElement* prev_; //!< The previous element in the list 61 OrxonoxClass* objectBase_; 62 }; 63 64 65 // ############################### 66 // ### ObjectListElement ### 67 // ############################### 68 //! The list-element that actually contains the object 69 template <class T> 70 class ObjectListElement : public ObjectListBaseElement 71 { 72 public: 73 ObjectListElement(T* object) : ObjectListBaseElement(object), object_(object) {} 74 T* object_; //!< The object 62 75 }; 63 76 … … 79 92 ~ObjectListBase(); 80 93 81 ObjectListBaseElement* add(OrxonoxClass* object); 94 ObjectListBaseElement* add(ObjectListBaseElement* element); 95 96 struct Export 97 { 98 Export(ObjectListBase* list, ObjectListBaseElement* element) : list_(list), element_(element) {} 99 ObjectListBase* list_; 100 ObjectListBaseElement* element_; 101 }; 82 102 83 103 /** @brief Returns a pointer to the first element in the list. @return The element */ 84 inline ObjectListBaseElement* begin() const { return this->first_; }104 inline Export begin() { return ObjectListBase::Export(this, this->first_); } 85 105 /** @brief Returns a pointer to the element after the last element in the list. @return The element */ 86 inline ObjectListBaseElement* end() const { return 0; }106 inline Export end() { return ObjectListBase::Export(this, 0); } 87 107 /** @brief Returns a pointer to the last element in the list. @return The element */ 88 inline ObjectListBaseElement* rbegin() const { return this->last_; }108 inline Export rbegin() { return ObjectListBase::Export(this, this->last_); } 89 109 /** @brief Returns a pointer to the element in front of the first element in the list. @return The element */ 90 inline ObjectListBaseElement* rend() const { return 0; }110 inline Export rend() { return ObjectListBase::Export(this, 0); } 91 111 92 inline void registerIterator(IteratorBase* iterator)93 { this->iterators_.insert(this->iterators_.end(),iterator); }94 inline void unregisterIterator(IteratorBase* iterator)95 { this->iterators_.erase(iterator); }96 void notifyIterators(O bjectListBaseElement* element);112 inline std::list<void*>::iterator registerIterator(void* iterator) { return this->iterators_.insert(this->iterators_.begin(), iterator); } 113 inline void unregisterIterator(const std::list<void*>::iterator& iterator) { this->iterators_.erase(iterator); } 114 inline std::list<void*>::iterator registerObjectListIterator(void* iterator) { return this->objectListIterators_.insert(this->iterators_.begin(), iterator); } 115 inline void unregisterObjectListIterator(const std::list<void*>::iterator& iterator) { this->objectListIterators_.erase(iterator); } 116 void notifyIterators(OrxonoxClass* object) const; 97 117 98 118 inline Identifier* getIdentifier() const { return this->identifier_; } 99 119 100 120 private: 101 Identifier* identifier_; //!< The Iterator owning this list 102 ObjectListBaseElement* first_; //!< The first element in the list 103 ObjectListBaseElement* last_; //!< The last element in the list 104 std::set<IteratorBase*> iterators_; //!< A list of iterators pointing on an element in this list 121 Identifier* identifier_; //!< The Iterator owning this list 122 ObjectListBaseElement* first_; //!< The first element in the list 123 ObjectListBaseElement* last_; //!< The last element in the list 124 std::list<void*> iterators_; //!< A list of Iterators pointing on an element in this list 125 std::list<void*> objectListIterators_; //!< A list of ObjectListIterators pointing on an element in this list 105 126 }; 106 127 }
Note: See TracChangeset
for help on using the changeset viewer.