Changeset 9608 for code/branches/core6/src
- Timestamp:
- Mar 30, 2013, 10:40:48 PM (12 years ago)
- Location:
- code/branches/core6/src/libraries/core/object
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/object/Context.cc
r9606 r9608 47 47 /*static*/ Context* Context::getRootContext() 48 48 { 49 static Context rootContext (NULL);49 static Context rootContext; 50 50 return &rootContext; 51 51 } -
code/branches/core6/src/libraries/core/object/Context.h
r9606 r9608 39 39 #include <vector> 40 40 41 #include "ObjectListBase.h"42 43 41 namespace orxonox 44 42 { … … 48 46 static Context* getRootContext(); 49 47 50 Context(Context* context );48 Context(Context* context = NULL); 51 49 virtual ~Context(); 52 50 -
code/branches/core6/src/libraries/core/object/Listable.cc
r9606 r9608 64 64 this->elements_.clear(); 65 65 } 66 67 /** 68 * @brief Changes the context. 69 * The object is removed from the current context and added to the new one. This also applies to all object lists the object is registered in. 70 */ 71 void Listable::setContext(Context* context) 72 { 73 this->context_ = context; 74 for (size_t i = 0; i < this->elements_.size(); ++i) 75 this->elements_[i]->changeContext(context); 76 } 77 66 78 } -
code/branches/core6/src/libraries/core/object/Listable.h
r9606 r9608 57 57 void unregisterObject(); 58 58 59 inline void setContext(Context* context) 60 { this->context_ = context; } 59 void setContext(Context* context); 61 60 inline Context* getContext() const 62 61 { return this->context_; } -
code/branches/core6/src/libraries/core/object/ObjectListBase.cc
r9606 r9608 41 41 namespace orxonox 42 42 { 43 ObjectListBaseElement::~ObjectListBaseElement() 43 // ############################### 44 // ### ObjectListBaseElement ### 45 // ############################### 46 void ObjectListBaseElement::removeFromList() 44 47 { 45 48 if (this->list_) … … 47 50 } 48 51 52 // ############################### 53 // ### ObjectListBase ### 54 // ############################### 49 55 /** 50 56 @brief Constructor: Sets default values. -
code/branches/core6/src/libraries/core/object/ObjectListBase.h
r9606 r9608 42 42 #include "core/CorePrereqs.h" 43 43 #include <vector> 44 #include "Context.h" 44 45 45 46 namespace orxonox … … 57 58 */ 58 59 ObjectListBaseElement(Listable* object) : next_(0), prev_(0), objectBase_(object), list_(0) {} 59 ~ObjectListBaseElement(); 60 virtual ~ObjectListBaseElement() { this->removeFromList(); } 61 62 virtual void changeContext(Context* context) = 0; 60 63 61 64 ObjectListBaseElement* next_; //!< The next element in the list … … 63 66 Listable* objectBase_; //!< The object 64 67 ObjectListBase* list_; //!< The list 68 69 protected: 70 void removeFromList(); 65 71 }; 66 72 … … 75 81 public: 76 82 ObjectListElement(T* object) : ObjectListBaseElement(static_cast<Listable*>(object)), object_(object) {} 83 84 virtual void changeContext(Context* context) 85 { 86 this->removeFromList(); 87 context->getObjectList<T>()->addElement(this); 88 } 89 77 90 T* object_; //!< The object 78 91 };
Note: See TracChangeset
for help on using the changeset viewer.