Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 872 was 871, checked in by landauf, 16 years ago

merged core branch to trunk

File size: 9.4 KB
RevLine 
[790]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
[871]28/**
[790]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
[162]36#ifndef _OrxonoxClass_H__
37#define _OrxonoxClass_H__
38
[871]39#include <list>
[790]40#include <string>
41
42#include "CorePrereqs.h"
[246]43#include "MetaObjectList.h"
[790]44#include "Iterator.h"
[197]45
[162]46namespace orxonox
47{
[790]48    //! The class all objects and interfaces of the game-logic (not the engine) are derived from.
49    /**
[871]50        The BaseObject and Interfaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass.
[790]51        OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList.
52    */
53    class _CoreExport OrxonoxClass
[162]54    {
55        public:
56            OrxonoxClass();
[218]57            virtual ~OrxonoxClass();
[790]58
59            /** @brief Function to collect the SetConfigValue-macro calls. */
60            void setConfigValues() {};
61
[871]62            /** @brief Returns the Identifier of the object. @return The Identifier */
[246]63            inline Identifier* getIdentifier() const { return this->identifier_; }
[790]64
65            /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */
[246]66            inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
[790]67
[871]68            /** @brief Returns the list of all parents of the object. @return The list */
69            inline std::list<const Identifier*>* getParents() const { return this->parents_; }
[790]70
[871]71            /** @brief Creates the parents-list. */
72            inline void createParents() { this->parents_ = new std::list<const Identifier*>(); }
[162]73
[871]74            /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */
[790]75            inline MetaObjectList& getMetaList() { return this->metaList_; }
76
77
[871]78            /** @brief Returns true if the objects class is of the given type or a derivative. */
[790]79            inline bool isA(const Identifier* identifier)
80                { return this->getIdentifier()->isA(identifier); }
[871]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. */
[790]85            inline bool isChildOf(const Identifier* identifier)
86                { return this->getIdentifier()->isChildOf(identifier); }
[871]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. */
[790]91            inline bool isParentOf(const Identifier* identifier)
92                { return this->getIdentifier()->isParentOf(identifier); }
[871]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); }
[790]96
97
[871]98            /** @brief Returns true if the objects class is of the given type or a derivative. */
[790]99            inline bool isA(const SubclassIdentifier<class B>* identifier)
100                { return this->getIdentifier()->isA(identifier->getIdentifier()); }
[871]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. */
[790]105            inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
106                { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
[871]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. */
[790]111            inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
112                { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
[871]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()); }
[790]116
117
[871]118            /** @brief Returns true if the objects class is of the given type or a derivative. */
[790]119            inline bool isA(const SubclassIdentifier<class B> identifier)
120                { return this->getIdentifier()->isA(identifier.getIdentifier()); }
[871]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. */
[790]125            inline bool isChildOf(const SubclassIdentifier<class B> identifier)
126                { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
[871]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. */
[790]131            inline bool isParentOf(const SubclassIdentifier<class B> identifier)
132                { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
[871]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()); }
[790]136
137
[871]138            /** @brief Returns true if the objects class is of the given type or a derivative. */
[790]139            inline bool isA(const OrxonoxClass* object)
140                { return this->getIdentifier()->isA(object->getIdentifier()); }
[871]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. */
[790]145            inline bool isChildOf(const OrxonoxClass* object)
146                { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
[871]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. */
[790]151            inline bool isParentOf(const OrxonoxClass* object)
152                { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
[871]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()); }
[790]156
[162]157        private:
[871]158            Identifier* identifier_;                    //!< The Identifier of the object
159            std::list<const Identifier*>* parents_;     //!< List of all parents of the object
160            MetaObjectList metaList_;                   //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
[162]161    };
162}
163
[790]164#endif /* _OrxonoxClass_H__ */
Note: See TracBrowser for help on using the repository browser.