Changeset 7849 for code/trunk/src/libraries/core/OrxonoxClass.h
- Timestamp:
- Feb 10, 2011, 9:52:23 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/OrxonoxClass.h
r7401 r7849 74 74 friend class SmartPtr; 75 75 76 template <class T> 77 friend class WeakPtr; 76 friend class DestructionListener; 78 77 79 78 public: … … 169 168 } 170 169 171 /// Register a weak pointer which points to this object. 172 template <class T> 173 inline void registerWeakPtr(WeakPtr<T>* pointer) 174 { this->weakPointers_.insert(reinterpret_cast<WeakPtr<OrxonoxClass>*>(pointer)); } 175 /// Unegister a weak pointer which pointed to this object before. 176 template <class T> 177 inline void unregisterWeakPtr(WeakPtr<T>* pointer) 178 { this->weakPointers_.erase(reinterpret_cast<WeakPtr<OrxonoxClass>*>(pointer)); } 179 180 Identifier* identifier_; //!< The Identifier of the object 181 std::set<const Identifier*>* parents_; //!< List of all parents of the object 182 MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in 183 int referenceCount_; //!< Counts the references from smart pointers to this object 184 bool requestedDestruction_; //!< Becomes true after someone called delete on this object 185 std::set<WeakPtr<OrxonoxClass>*> weakPointers_; //!< All weak pointers which point to this object (and like to get notified if it dies) 170 /// Register a destruction listener (for example a weak pointer which points to this object). 171 inline void registerDestructionListener(DestructionListener* pointer) 172 { this->destructionListeners_.insert(pointer); } 173 /// Unegister a destruction listener (for example a weak pointer which pointed to this object before). 174 inline void unregisterDestructionListener(DestructionListener* pointer) 175 { this->destructionListeners_.erase(pointer); } 176 177 Identifier* identifier_; //!< The Identifier of the object 178 std::set<const Identifier*>* parents_; //!< List of all parents of the object 179 MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in 180 int referenceCount_; //!< Counts the references from smart pointers to this object 181 bool requestedDestruction_; //!< Becomes true after someone called delete on this object 182 std::set<DestructionListener*> destructionListeners_; //!< All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies) 186 183 187 184 /// 'Fast map' that holds this-pointers of all derived types … … 189 186 }; 190 187 188 /** 189 @brief This listener is used to inform weak pointers if an object of type OrxonoxClass gets destroyed. 190 */ 191 class _CoreExport DestructionListener 192 { 193 friend class OrxonoxClass; 194 195 protected: 196 inline void registerAsDestructionListener(OrxonoxClass* object) 197 { object->registerDestructionListener(this); } 198 inline void unregisterAsDestructionListener(OrxonoxClass* object) 199 { object->unregisterDestructionListener(this); } 200 201 virtual void objectDeleted() = 0; 202 }; 203 191 204 SUPER_FUNCTION(11, OrxonoxClass, clone, false); 192 193 205 } 194 206
Note: See TracChangeset
for help on using the changeset viewer.