Changeset 7401 for code/trunk/src/libraries/core/OrxonoxClass.h
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/OrxonoxClass.h
r7163 r7401 28 28 29 29 /** 30 @defgroup OrxonoxClass OrxonoxClass 31 @ingroup Class 32 */ 33 34 /** 30 35 @file 31 @brief Declaration of the OrxonoxClass Class. 36 @ingroup Class OrxonoxClass 37 @brief Declaration of OrxonoxClass, the base class of all objects and interfaces in Orxonox. 32 38 33 39 All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass. … … 53 59 namespace orxonox 54 60 { 55 //! The class all objects and interfaces of the game-logic (not the engine) are derived from.56 61 /** 57 The BaseObject and Interfaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass. 58 OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList. 62 @brief The class all objects and interfaces of the game-logic (not the engine) are derived from. 63 64 The BaseObject and Interfaces are derived with @c virtual @c public @c OrxonoxClass from OrxonoxClass. 65 OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the 66 MetaObjectList, as well as to provide an interface for SmartPtr and WeakPtr. 59 67 */ 60 68 class _CoreExport OrxonoxClass … … 76 84 void unregisterObject(); 77 85 78 / ** @brief Function to collect the SetConfigValue-macro calls. */86 /// Function to collect the SetConfigValue-macro calls. 79 87 void setConfigValues() {}; 80 88 81 / ** @brief Returns the Identifier of the object. @return The Identifier */89 /// Returns the Identifier of the object. 82 90 inline Identifier* getIdentifier() const { return this->identifier_; } 83 91 … … 89 97 bool isDirectParentOf(const Identifier* identifier); 90 98 99 /// Returns true if the object's class is of the given type or a derivative. 91 100 template <class B> inline bool isA(const SubclassIdentifier<B>* identifier) 92 101 { return this->isA(*identifier); } 102 /// Returns true if the object's class is exactly of the given type. 93 103 template <class B> inline bool isExactlyA(const SubclassIdentifier<B>* identifier) 94 104 { return this->isExactlyA(*identifier); } 105 /// Returns true if the object's class is a child of the given type. 95 106 template <class B> inline bool isChildOf(const SubclassIdentifier<B>* identifier) 96 107 { return this->isChildOf(*identifier); } 108 /// Returns true if the object's class is a direct child of the given type. 97 109 template <class B> inline bool isDirectChildOf(const SubclassIdentifier<B>* identifier) 98 110 { return this->isDirectChildOf(*identifier); } 111 /// Returns true if the object's class is a parent of the given type. 99 112 template <class B> inline bool isParentOf(const SubclassIdentifier<B>* identifier) 100 113 { return this->isParentOf(*identifier); } 114 /// Returns true if the object's class is a direct parent of the given type. 101 115 template <class B> inline bool isDirectParentOf(const SubclassIdentifier<B>* identifier) 102 116 { return this->isDirectParentOf(*identifier); } … … 111 125 virtual void clone(OrxonoxClass*& item) {} 112 126 127 /// Returns the number of @ref orxonox::SmartPtr "smart pointers" that point to this object. 113 128 inline unsigned int getReferenceCount() const 114 129 { return this->referenceCount_; } … … 131 146 } 132 147 133 // !Version of getDerivedPointer with template148 /// Version of getDerivedPointer with template 134 149 template <class T> FORCEINLINE T* getDerivedPointer(unsigned int classID) 135 150 { return static_cast<T*>(this->getDerivedPointer(classID)); } 136 // !Const version of getDerivedPointer with template151 /// Const version of getDerivedPointer with template 137 152 template <class T> FORCEINLINE const T* getDerivedPointer(unsigned int classID) const 138 153 { return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID); } 139 154 140 155 protected: 156 /// This virtual function is called if destroy() is called and no SmartPtr points to this object. Used in some cases to create a new SmartPtr to prevent destruction. 141 157 virtual void preDestroy() {} 142 158 143 159 private: 144 / ** @brief Increments the reference counter (for smart pointers). */160 /// Increments the reference counter (for smart pointers). 145 161 inline void incrementReferenceCount() 146 162 { ++this->referenceCount_; } 147 / ** @brief Decrements the reference counter (for smart pointers). */163 /// Decrements the reference counter (for smart pointers). 148 164 inline void decrementReferenceCount() 149 165 { … … 153 169 } 154 170 155 / ** @brief Register a weak pointer which points to this object. */171 /// Register a weak pointer which points to this object. 156 172 template <class T> 157 173 inline void registerWeakPtr(WeakPtr<T>* pointer) 158 174 { this->weakPointers_.insert(reinterpret_cast<WeakPtr<OrxonoxClass>*>(pointer)); } 159 / ** @brief Unegister a weak pointer which pointed to this object before. */175 /// Unegister a weak pointer which pointed to this object before. 160 176 template <class T> 161 177 inline void unregisterWeakPtr(WeakPtr<T>* pointer) 162 178 { this->weakPointers_.erase(reinterpret_cast<WeakPtr<OrxonoxClass>*>(pointer)); } 163 179 164 Identifier* identifier_; //!< The Identifier of the object165 std::set<const Identifier*>* parents_; //!< List of all parents of the object166 MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in167 int referenceCount_; //!< Counts the references from smart pointers to this object168 bool requestedDestruction_; //!< Becomes true after someone called delete on this object169 std::set<WeakPtr<OrxonoxClass>*> weakPointers_; //!< All weak pointers which point to this object (and like to get notified if it dies)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 186 171 // !'Fast map' that holds this-pointers of all derived types187 /// 'Fast map' that holds this-pointers of all derived types 172 188 std::vector<std::pair<unsigned int, void*> > objectPointers_; 173 189 };
Note: See TracChangeset
for help on using the changeset viewer.