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