Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/core/OrxonoxClass.h @ 1054

Last change on this file since 1054 was 1052, checked in by landauf, 17 years ago

merged core2 back to trunk
there might be some errors, wasn't able to test it yet due to some strange g++ and linker behaviour.

File size: 9.4 KB
Line 
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 <set>
40#include <string>
41
42#include "CorePrereqs.h"
43#include "MetaObjectList.h"
44#include "Iterator.h"
45
46namespace orxonox
47{
48    //! The class all objects and interfaces of the game-logic (not the engine) are derived from.
49    /**
50        The BaseObject and Interfaces 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            /** @brief Returns the Identifier of the object. @return The Identifier */
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            /** @brief Returns the list of all parents of the object. @return The list */
69            inline std::set<const Identifier*>* getParents() const { return this->parents_; }
70
71            /** @brief Creates the parents-list. */
72            inline void createParents() { this->parents_ = new std::set<const Identifier*>(); }
73
74            /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */
75            inline MetaObjectList& getMetaList() { return this->metaList_; }
76
77
78            /** @brief 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            /** @brief Returns true if the objects class is exactly of the given type. */
82            inline bool isExactlyA(const Identifier* identifier)
83                { return this->getIdentifier()->isExactlyA(identifier); }
84            /** @brief 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            /** @brief Returns true if the objects class is a direct child of the given type. */
88            inline bool isDirectChildOf(const Identifier* identifier)
89                { return this->getIdentifier()->isDirectChildOf(identifier); }
90            /** @brief Returns true if the objects class is a parent of the given type. */
91            inline bool isParentOf(const Identifier* identifier)
92                { return this->getIdentifier()->isParentOf(identifier); }
93            /** @brief Returns true if the objects class is a direct parent of the given type. */
94            inline bool isDirectParentOf(const Identifier* identifier)
95                { return this->getIdentifier()->isDirectParentOf(identifier); }
96
97
98            /** @brief Returns true if the objects class is of the given type or a derivative. */
99            inline bool isA(const SubclassIdentifier<class B>* identifier)
100                { return this->getIdentifier()->isA(identifier->getIdentifier()); }
101            /** @brief Returns true if the objects class is exactly of the given type. */
102            inline bool isExactlyA(const SubclassIdentifier<class B>* identifier)
103                { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); }
104            /** @brief Returns true if the objects class is a child of the given type. */
105            inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
106                { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
107            /** @brief Returns true if the objects class is a direct child of the given type. */
108            inline bool isDirectChildOf(const SubclassIdentifier<class B>* identifier)
109                { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); }
110            /** @brief Returns true if the objects class is a parent of the given type. */
111            inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
112                { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
113            /** @brief Returns true if the objects class is a direct parent of the given type. */
114            inline bool isDirectParentOf(const SubclassIdentifier<class B>* identifier)
115                { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); }
116
117
118            /** @brief Returns true if the objects class is of the given type or a derivative. */
119            inline bool isA(const SubclassIdentifier<class B> identifier)
120                { return this->getIdentifier()->isA(identifier.getIdentifier()); }
121            /** @brief Returns true if the objects class is exactly of the given type. */
122            inline bool isExactlyA(const SubclassIdentifier<class B> identifier)
123                { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); }
124            /** @brief Returns true if the objects class is a child of the given type. */
125            inline bool isChildOf(const SubclassIdentifier<class B> identifier)
126                { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
127            /** @brief Returns true if the objects class is a direct child of the given type. */
128            inline bool isDirectChildOf(const SubclassIdentifier<class B> identifier)
129                { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); }
130            /** @brief Returns true if the objects class is a parent of the given type. */
131            inline bool isParentOf(const SubclassIdentifier<class B> identifier)
132                { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
133            /** @brief Returns true if the objects class is a direct parent of the given type. */
134            inline bool isDirectParentOf(const SubclassIdentifier<class B> identifier)
135                { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
136
137
138            /** @brief Returns true if the objects class is of the given type or a derivative. */
139            inline bool isA(const OrxonoxClass* object)
140                { return this->getIdentifier()->isA(object->getIdentifier()); }
141            /** @brief Returns true if the objects class is exactly of the given type. */
142            inline bool isExactlyA(const OrxonoxClass* object)
143                { return this->getIdentifier()->isExactlyA(object->getIdentifier()); }
144            /** @brief Returns true if the objects class is a child of the given type. */
145            inline bool isChildOf(const OrxonoxClass* object)
146                { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
147            /** @brief Returns true if the objects class is a direct child of the given type. */
148            inline bool isDirectChildOf(const OrxonoxClass* object)
149                { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); }
150            /** @brief Returns true if the objects class is a parent of the given type. */
151            inline bool isParentOf(const OrxonoxClass* object)
152                { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
153            /** @brief Returns true if the objects class is a direct child of the given type. */
154            inline bool isDirectParentOf(const OrxonoxClass* object)
155                { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
156
157        private:
158            Identifier* identifier_;                    //!< The Identifier of the object
159            std::set<const Identifier*>* parents_;     //!< List of all parents of the object
160            MetaObjectList metaList_;                   //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
161    };
162}
163
164#endif /* _OrxonoxClass_H__ */
Note: See TracBrowser for help on using the repository browser.