- Timestamp:
- Mar 24, 2013, 6:34:23 PM (11 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/class/Identifiable.cc
r9563 r9565 32 32 */ 33 33 34 #include " OrxonoxClass.h"34 #include "Identifiable.h" 35 35 36 36 #include <cassert> … … 44 44 @brief Constructor: Sets the default values. 45 45 */ 46 OrxonoxClass::OrxonoxClass()46 Identifiable::Identifiable() 47 47 { 48 48 this->identifier_ = 0; 49 49 this->parents_ = 0; 50 50 this->metaList_ = new MetaObjectList(); 51 this->referenceCount_ = 0;52 this->requestedDestruction_ = false;53 51 // Optimisation 54 52 this->objectPointers_.reserve(6); … … 56 54 57 55 /** 58 @brief Destructor: Removes the object from the object-lists , notifies all DestructionListener (for example @ref WeakPtr "weak pointers") that this object is being deleted.56 @brief Destructor: Removes the object from the object-lists 59 57 */ 60 OrxonoxClass::~OrxonoxClass()58 Identifiable::~Identifiable() 61 59 { 62 60 // if (!this->requestedDestruction_) 63 61 // orxout(internal_warning) << "Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << endl; 64 65 assert(this->referenceCount_ <= 0);66 62 67 63 this->unregisterObject(); … … 70 66 if (this->parents_) 71 67 delete this->parents_; 72 73 // notify all destruction listeners74 for (std::set<DestructionListener*>::iterator it = this->destructionListeners_.begin(); it != this->destructionListeners_.end(); )75 (*(it++))->objectDeleted();76 }77 78 /**79 @brief Deletes the object if no @ref orxonox::SmartPtr "smart pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible.80 */81 void OrxonoxClass::destroy()82 {83 assert(this); // Just in case someone tries to delete a NULL pointer84 this->requestedDestruction_ = true;85 if (this->referenceCount_ == 0)86 {87 this->preDestroy();88 if (this->referenceCount_ == 0)89 delete this;90 }91 68 } 92 69 … … 94 71 @brief Removes this object from the object-lists. 95 72 */ 96 void OrxonoxClass::unregisterObject()73 void Identifiable::unregisterObject() 97 74 { 98 75 if (this->metaList_) … … 102 79 103 80 /// Returns true if the object's class is of the given type or a derivative. 104 bool OrxonoxClass::isA(const Identifier* identifier)81 bool Identifiable::isA(const Identifier* identifier) 105 82 { return this->getIdentifier()->isA(identifier); } 106 83 /// Returns true if the object's class is exactly of the given type. 107 bool OrxonoxClass::isExactlyA(const Identifier* identifier)84 bool Identifiable::isExactlyA(const Identifier* identifier) 108 85 { return this->getIdentifier()->isExactlyA(identifier); } 109 86 /// Returns true if the object's class is a child of the given type. 110 bool OrxonoxClass::isChildOf(const Identifier* identifier)87 bool Identifiable::isChildOf(const Identifier* identifier) 111 88 { return this->getIdentifier()->isChildOf(identifier); } 112 89 /// Returns true if the object's class is a direct child of the given type. 113 bool OrxonoxClass::isDirectChildOf(const Identifier* identifier)90 bool Identifiable::isDirectChildOf(const Identifier* identifier) 114 91 { return this->getIdentifier()->isDirectChildOf(identifier); } 115 92 /// Returns true if the object's class is a parent of the given type. 116 bool OrxonoxClass::isParentOf(const Identifier* identifier)93 bool Identifiable::isParentOf(const Identifier* identifier) 117 94 { return this->getIdentifier()->isParentOf(identifier); } 118 95 /// Returns true if the object's class is a direct parent of the given type. 119 bool OrxonoxClass::isDirectParentOf(const Identifier* identifier)96 bool Identifiable::isDirectParentOf(const Identifier* identifier) 120 97 { return this->getIdentifier()->isDirectParentOf(identifier); } 121 98 122 99 123 100 /// Returns true if the object's class is of the given type or a derivative. 124 bool OrxonoxClass::isA(const OrxonoxClass* object)101 bool Identifiable::isA(const Identifiable* object) 125 102 { return this->getIdentifier()->isA(object->getIdentifier()); } 126 103 /// Returns true if the object's class is exactly of the given type. 127 bool OrxonoxClass::isExactlyA(const OrxonoxClass* object)104 bool Identifiable::isExactlyA(const Identifiable* object) 128 105 { return this->getIdentifier()->isExactlyA(object->getIdentifier()); } 129 106 /// Returns true if the object's class is a child of the given type. 130 bool OrxonoxClass::isChildOf(const OrxonoxClass* object)107 bool Identifiable::isChildOf(const Identifiable* object) 131 108 { return this->getIdentifier()->isChildOf(object->getIdentifier()); } 132 109 /// Returns true if the object's class is a direct child of the given type. 133 bool OrxonoxClass::isDirectChildOf(const OrxonoxClass* object)110 bool Identifiable::isDirectChildOf(const Identifiable* object) 134 111 { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); } 135 112 /// Returns true if the object's class is a parent of the given type. 136 bool OrxonoxClass::isParentOf(const OrxonoxClass* object)113 bool Identifiable::isParentOf(const Identifiable* object) 137 114 { return this->getIdentifier()->isParentOf(object->getIdentifier()); } 138 115 /// Returns true if the object's class is a direct child of the given type. 139 bool OrxonoxClass::isDirectParentOf(const OrxonoxClass* object)116 bool Identifiable::isDirectParentOf(const Identifiable* object) 140 117 { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); } 141 118 }
Note: See TracChangeset
for help on using the changeset viewer.