Changeset 9661
- Timestamp:
- Aug 24, 2013, 6:38:55 PM (11 years ago)
- Location:
- code/branches/core6
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/object/Context.h
r9649 r9661 64 64 inline void addObject(T* object) 65 65 { 66 ObjectListBaseElement* element = this->getObjectList<T>()->add(object); 66 ObjectListBaseElement* element = Listable::createObjectListElement(object); 67 this->getObjectList<T>()->addElement(element); 67 68 object->elements_.push_back(element); 68 69 if (this->getParentContext()) -
code/branches/core6/src/libraries/core/object/Listable.cc
r9651 r9661 77 77 { 78 78 for (size_t i = 0; i < this->elements_.size(); ++i) 79 delete this->elements_[i];79 Listable::deleteObjectListElement(this->elements_[i]); 80 80 this->elements_.clear(); 81 81 } … … 94 94 { 95 95 copy[i]->changeContext(this->context_, context); 96 delete copy[i];96 Listable::deleteObjectListElement(copy[i]); 97 97 } 98 98 … … 100 100 } 101 101 102 /* static */ void Listable::deleteObjectListElement(ObjectListBaseElement* element) 103 { 104 delete element; 105 } 102 106 } -
code/branches/core6/src/libraries/core/object/Listable.h
r9610 r9661 63 63 64 64 private: 65 template <class T> 66 static ObjectListElement<T>* createObjectListElement(T* object) 67 { 68 return new ObjectListElement<T>(object); 69 } 70 71 static void deleteObjectListElement(ObjectListBaseElement* element); 72 65 73 Context* context_; //!< The object will register itself in the object lists of this context 66 74 std::vector<ObjectListBaseElement*> elements_; //!< The corresponding ObjectListElements in all object lists the object is registered in -
code/branches/core6/src/libraries/core/object/ObjectListBase.h
r9627 r9661 128 128 ~ObjectListBase(); 129 129 130 template <class T>131 inline ObjectListBaseElement* add(T* object)132 {133 ObjectListBaseElement* element = new ObjectListElement<T>(object);134 this->addElement(element);135 return element;136 }137 138 130 void addElement(ObjectListBaseElement* element); 139 131 void removeElement(ObjectListBaseElement* element); -
code/branches/core6/test/core/object/ObjectListBaseTest.cc
r9608 r9661 43 43 { 44 44 ObjectListBase list; 45 list.add (static_cast<Listable*>(NULL));45 list.addElement(new ObjectListElement<Listable>(NULL)); 46 46 EXPECT_EQ(1u, list.size()); 47 47 }
Note: See TracChangeset
for help on using the changeset viewer.