- Timestamp:
- Mar 24, 2013, 6:34:23 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/class/OrxonoxClass.h
r9563 r9565 36 36 @ingroup Class OrxonoxClass 37 37 @brief Declaration of OrxonoxClass, the base class of all objects and interfaces in Orxonox. 38 39 All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass.40 It stores the Identifier and the MetaObjectList and has all needed functions to create and use the class-hierarchy.41 38 */ 42 39 … … 47 44 48 45 #include <set> 49 #include <vector> 50 #include " Super.h"46 //#include "Super.h" 47 #include "Identifiable.h" 51 48 52 49 namespace orxonox … … 56 53 57 54 The BaseObject and Interfaces are derived with @c virtual @c public @c OrxonoxClass from OrxonoxClass. 58 OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the59 MetaObjectList, as well as to provide an interface for SmartPtr and WeakPtr.60 55 */ 61 class _CoreExport OrxonoxClass 56 class _CoreExport OrxonoxClass : public Identifiable 62 57 { 63 template <class T>64 friend class ClassIdentifier;65 66 58 template <class T> 67 59 friend class SmartPtr; … … 74 66 75 67 void destroy(); 76 void unregisterObject();77 68 78 69 /// Function to collect the SetConfigValue-macro calls. 79 70 void setConfigValues() {}; 80 71 81 /// Returns the Identifier of the object.82 inline Identifier* getIdentifier() const { return this->identifier_; }83 84 bool isA(const Identifier* identifier);85 bool isExactlyA(const Identifier* identifier);86 bool isChildOf(const Identifier* identifier);87 bool isDirectChildOf(const Identifier* identifier);88 bool isParentOf(const Identifier* identifier);89 bool isDirectParentOf(const Identifier* identifier);90 91 /// Returns true if the object's class is of the given type or a derivative.92 template <class B> inline bool isA(const SubclassIdentifier<B>* identifier)93 { return this->isA(*identifier); }94 /// Returns true if the object's class is exactly of the given type.95 template <class B> inline bool isExactlyA(const SubclassIdentifier<B>* identifier)96 { return this->isExactlyA(*identifier); }97 /// Returns true if the object's class is a child of the given type.98 template <class B> inline bool isChildOf(const SubclassIdentifier<B>* identifier)99 { return this->isChildOf(*identifier); }100 /// Returns true if the object's class is a direct child of the given type.101 template <class B> inline bool isDirectChildOf(const SubclassIdentifier<B>* identifier)102 { return this->isDirectChildOf(*identifier); }103 /// Returns true if the object's class is a parent of the given type.104 template <class B> inline bool isParentOf(const SubclassIdentifier<B>* identifier)105 { return this->isParentOf(*identifier); }106 /// Returns true if the object's class is a direct parent of the given type.107 template <class B> inline bool isDirectParentOf(const SubclassIdentifier<B>* identifier)108 { return this->isDirectParentOf(*identifier); }109 110 bool isA(const OrxonoxClass* object);111 bool isExactlyA(const OrxonoxClass* object);112 bool isChildOf(const OrxonoxClass* object);113 bool isDirectChildOf(const OrxonoxClass* object);114 bool isParentOf(const OrxonoxClass* object);115 bool isDirectParentOf(const OrxonoxClass* object);116 117 72 /// Returns the number of @ref orxonox::SmartPtr "smart pointers" that point to this object. 118 73 inline unsigned int getReferenceCount() const 119 74 { return this->referenceCount_; } 120 121 /**122 @brief123 Returns a valid pointer of any derived type that is124 registered in the class hierarchy.125 @return126 Returns NULL if the no pointer was found.127 */128 ORX_FORCEINLINE void* getDerivedPointer(unsigned int classID)129 {130 for (int i = this->objectPointers_.size() - 1; i >= 0; --i)131 {132 if (this->objectPointers_[i].first == classID)133 return this->objectPointers_[i].second;134 }135 return NULL;136 }137 138 /// Version of getDerivedPointer with template139 template <class T> ORX_FORCEINLINE T* getDerivedPointer(unsigned int classID)140 { return static_cast<T*>(this->getDerivedPointer(classID)); }141 /// Const version of getDerivedPointer with template142 template <class T> ORX_FORCEINLINE const T* getDerivedPointer(unsigned int classID) const143 { return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID); }144 75 145 76 protected: … … 166 97 { this->destructionListeners_.erase(pointer); } 167 98 168 Identifier* identifier_; //!< The Identifier of the object169 std::set<const Identifier*>* parents_; //!< List of all parents of the object170 MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in171 99 int referenceCount_; //!< Counts the references from smart pointers to this object 172 100 bool requestedDestruction_; //!< Becomes true after someone called delete on this object 173 101 std::set<DestructionListener*> destructionListeners_; //!< All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies) 174 175 /// 'Fast map' that holds this-pointers of all derived types176 std::vector<std::pair<unsigned int, void*> > objectPointers_;177 102 }; 178 103
Note: See TracChangeset
for help on using the changeset viewer.