[790] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
[1056] | 3 | * > www.orxonox.net < |
---|
[790] | 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[871] | 29 | /** |
---|
[790] | 30 | @file OrxonoxClass.h |
---|
| 31 | @brief Definition of the OrxonoxClass Class. |
---|
| 32 | |
---|
| 33 | All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass. |
---|
| 34 | It stores the Identifier and the MetaObjectList and has all needed functions to create and use the class-hierarchy. |
---|
| 35 | */ |
---|
| 36 | |
---|
[162] | 37 | #ifndef _OrxonoxClass_H__ |
---|
| 38 | #define _OrxonoxClass_H__ |
---|
| 39 | |
---|
[1052] | 40 | #include <set> |
---|
[790] | 41 | #include <string> |
---|
| 42 | |
---|
| 43 | #include "CorePrereqs.h" |
---|
[246] | 44 | #include "MetaObjectList.h" |
---|
[790] | 45 | #include "Iterator.h" |
---|
[197] | 46 | |
---|
[162] | 47 | namespace orxonox |
---|
| 48 | { |
---|
[790] | 49 | //! The class all objects and interfaces of the game-logic (not the engine) are derived from. |
---|
| 50 | /** |
---|
[871] | 51 | The BaseObject and Interfaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass. |
---|
[790] | 52 | OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList. |
---|
| 53 | */ |
---|
| 54 | class _CoreExport OrxonoxClass |
---|
[162] | 55 | { |
---|
| 56 | public: |
---|
| 57 | OrxonoxClass(); |
---|
[218] | 58 | virtual ~OrxonoxClass(); |
---|
[790] | 59 | |
---|
| 60 | /** @brief Function to collect the SetConfigValue-macro calls. */ |
---|
| 61 | void setConfigValues() {}; |
---|
| 62 | |
---|
[871] | 63 | /** @brief Returns the Identifier of the object. @return The Identifier */ |
---|
[246] | 64 | inline Identifier* getIdentifier() const { return this->identifier_; } |
---|
[790] | 65 | |
---|
| 66 | /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */ |
---|
[246] | 67 | inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; } |
---|
[790] | 68 | |
---|
[871] | 69 | /** @brief Returns the list of all parents of the object. @return The list */ |
---|
[1052] | 70 | inline std::set<const Identifier*>* getParents() const { return this->parents_; } |
---|
[790] | 71 | |
---|
[871] | 72 | /** @brief Creates the parents-list. */ |
---|
[1052] | 73 | inline void createParents() { this->parents_ = new std::set<const Identifier*>(); } |
---|
[162] | 74 | |
---|
[871] | 75 | /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */ |
---|
[790] | 76 | inline MetaObjectList& getMetaList() { return this->metaList_; } |
---|
| 77 | |
---|
| 78 | |
---|
[871] | 79 | /** @brief Returns true if the objects class is of the given type or a derivative. */ |
---|
[790] | 80 | inline bool isA(const Identifier* identifier) |
---|
| 81 | { return this->getIdentifier()->isA(identifier); } |
---|
[871] | 82 | /** @brief Returns true if the objects class is exactly of the given type. */ |
---|
| 83 | inline bool isExactlyA(const Identifier* identifier) |
---|
| 84 | { return this->getIdentifier()->isExactlyA(identifier); } |
---|
| 85 | /** @brief Returns true if the objects class is a child of the given type. */ |
---|
[790] | 86 | inline bool isChildOf(const Identifier* identifier) |
---|
| 87 | { return this->getIdentifier()->isChildOf(identifier); } |
---|
[871] | 88 | /** @brief Returns true if the objects class is a direct child of the given type. */ |
---|
| 89 | inline bool isDirectChildOf(const Identifier* identifier) |
---|
| 90 | { return this->getIdentifier()->isDirectChildOf(identifier); } |
---|
| 91 | /** @brief Returns true if the objects class is a parent of the given type. */ |
---|
[790] | 92 | inline bool isParentOf(const Identifier* identifier) |
---|
| 93 | { return this->getIdentifier()->isParentOf(identifier); } |
---|
[871] | 94 | /** @brief Returns true if the objects class is a direct parent of the given type. */ |
---|
| 95 | inline bool isDirectParentOf(const Identifier* identifier) |
---|
| 96 | { return this->getIdentifier()->isDirectParentOf(identifier); } |
---|
[790] | 97 | |
---|
| 98 | |
---|
[871] | 99 | /** @brief Returns true if the objects class is of the given type or a derivative. */ |
---|
[790] | 100 | inline bool isA(const SubclassIdentifier<class B>* identifier) |
---|
| 101 | { return this->getIdentifier()->isA(identifier->getIdentifier()); } |
---|
[871] | 102 | /** @brief Returns true if the objects class is exactly of the given type. */ |
---|
| 103 | inline bool isExactlyA(const SubclassIdentifier<class B>* identifier) |
---|
| 104 | { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); } |
---|
| 105 | /** @brief Returns true if the objects class is a child of the given type. */ |
---|
[790] | 106 | inline bool isChildOf(const SubclassIdentifier<class B>* identifier) |
---|
| 107 | { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); } |
---|
[871] | 108 | /** @brief Returns true if the objects class is a direct child of the given type. */ |
---|
| 109 | inline bool isDirectChildOf(const SubclassIdentifier<class B>* identifier) |
---|
| 110 | { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); } |
---|
| 111 | /** @brief Returns true if the objects class is a parent of the given type. */ |
---|
[790] | 112 | inline bool isParentOf(const SubclassIdentifier<class B>* identifier) |
---|
| 113 | { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); } |
---|
[871] | 114 | /** @brief Returns true if the objects class is a direct parent of the given type. */ |
---|
| 115 | inline bool isDirectParentOf(const SubclassIdentifier<class B>* identifier) |
---|
| 116 | { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); } |
---|
[790] | 117 | |
---|
| 118 | |
---|
[871] | 119 | /** @brief Returns true if the objects class is of the given type or a derivative. */ |
---|
[790] | 120 | inline bool isA(const SubclassIdentifier<class B> identifier) |
---|
| 121 | { return this->getIdentifier()->isA(identifier.getIdentifier()); } |
---|
[871] | 122 | /** @brief Returns true if the objects class is exactly of the given type. */ |
---|
| 123 | inline bool isExactlyA(const SubclassIdentifier<class B> identifier) |
---|
| 124 | { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); } |
---|
| 125 | /** @brief Returns true if the objects class is a child of the given type. */ |
---|
[790] | 126 | inline bool isChildOf(const SubclassIdentifier<class B> identifier) |
---|
| 127 | { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); } |
---|
[871] | 128 | /** @brief Returns true if the objects class is a direct child of the given type. */ |
---|
| 129 | inline bool isDirectChildOf(const SubclassIdentifier<class B> identifier) |
---|
| 130 | { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); } |
---|
| 131 | /** @brief Returns true if the objects class is a parent of the given type. */ |
---|
[790] | 132 | inline bool isParentOf(const SubclassIdentifier<class B> identifier) |
---|
| 133 | { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); } |
---|
[871] | 134 | /** @brief Returns true if the objects class is a direct parent of the given type. */ |
---|
| 135 | inline bool isDirectParentOf(const SubclassIdentifier<class B> identifier) |
---|
| 136 | { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); } |
---|
[790] | 137 | |
---|
| 138 | |
---|
[871] | 139 | /** @brief Returns true if the objects class is of the given type or a derivative. */ |
---|
[790] | 140 | inline bool isA(const OrxonoxClass* object) |
---|
| 141 | { return this->getIdentifier()->isA(object->getIdentifier()); } |
---|
[871] | 142 | /** @brief Returns true if the objects class is exactly of the given type. */ |
---|
| 143 | inline bool isExactlyA(const OrxonoxClass* object) |
---|
| 144 | { return this->getIdentifier()->isExactlyA(object->getIdentifier()); } |
---|
| 145 | /** @brief Returns true if the objects class is a child of the given type. */ |
---|
[790] | 146 | inline bool isChildOf(const OrxonoxClass* object) |
---|
| 147 | { return this->getIdentifier()->isChildOf(object->getIdentifier()); } |
---|
[871] | 148 | /** @brief Returns true if the objects class is a direct child of the given type. */ |
---|
| 149 | inline bool isDirectChildOf(const OrxonoxClass* object) |
---|
| 150 | { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); } |
---|
| 151 | /** @brief Returns true if the objects class is a parent of the given type. */ |
---|
[790] | 152 | inline bool isParentOf(const OrxonoxClass* object) |
---|
| 153 | { return this->getIdentifier()->isParentOf(object->getIdentifier()); } |
---|
[871] | 154 | /** @brief Returns true if the objects class is a direct child of the given type. */ |
---|
| 155 | inline bool isDirectParentOf(const OrxonoxClass* object) |
---|
| 156 | { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); } |
---|
[790] | 157 | |
---|
[162] | 158 | private: |
---|
[871] | 159 | Identifier* identifier_; //!< The Identifier of the object |
---|
[1052] | 160 | std::set<const Identifier*>* parents_; //!< List of all parents of the object |
---|
[871] | 161 | MetaObjectList metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in |
---|
[162] | 162 | }; |
---|
| 163 | } |
---|
| 164 | |
---|
[790] | 165 | #endif /* _OrxonoxClass_H__ */ |
---|