Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapon/src/orxonox/core/OrxonoxClass.h @ 895

Last change on this file since 895 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

File size: 8.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 <string>
40
41#include "CorePrereqs.h"
42#include "MetaObjectList.h"
43#include "Iterator.h"
44
45namespace orxonox
46{
47    //! The class all objects and interfaces of the game-logic (not the engine) are derived from.
48    /**
49        The BaseObject and Interaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass.
50        OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList.
51    */
52    class _CoreExport OrxonoxClass
53    {
54        public:
55            OrxonoxClass();
56            virtual ~OrxonoxClass();
57
58            /** @brief Function to collect the SetConfigValue-macro calls. */
59            void setConfigValues() {};
60
61            /** @returns the Identifier of the object */
62            inline Identifier* getIdentifier() const { return this->identifier_; }
63
64            /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */
65            inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
66
67            /** @returns the list of all parents of the object */
68            inline IdentifierList* getParents() const { return this->parents_; }
69
70            /** @brief Sets the Parents of the object. Used by the RegisterObject-macro. */
71            inline void setParents(IdentifierList* parents) { this->parents_ = parents; }
72
73            /** @returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. */
74            inline MetaObjectList& getMetaList() { return this->metaList_; }
75
76
77            /** @returns true if the objects class is of the given type or a derivative. */
78            inline bool isA(const Identifier* identifier)
79                { return this->getIdentifier()->isA(identifier); }
80            /** @returns true if the objects class is exactly of the given type. */
81            inline bool isDirectlyA(const Identifier* identifier)
82                { return this->getIdentifier()->isDirectlyA(identifier); }
83            /** @returns true if the objects class is a child of the given type. */
84            inline bool isChildOf(const Identifier* identifier)
85                { return this->getIdentifier()->isChildOf(identifier); }
86            /** @returns true if the objects class is a parent of the given type. */
87            inline bool isParentOf(const Identifier* identifier)
88                { return this->getIdentifier()->isParentOf(identifier); }
89
90
91            /** @returns true if the objects class is of the given type or a derivative. */
92            inline bool isA(const SubclassIdentifier<class B>* identifier)
93                { return this->getIdentifier()->isA(identifier->getIdentifier()); }
94            /** @returns true if the objects class is exactly of the given type. */
95            inline bool isDirectlyA(const SubclassIdentifier<class B>* identifier)
96                { return this->getIdentifier()->isDirectlyA(identifier->getIdentifier()); }
97            /** @returns true if the objects class is a child of the given type. */
98            inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
99                { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
100            /** @returns true if the objects class is a parent of the given type. */
101            inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
102                { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
103
104
105            /** @returns true if the objects class is of the given type or a derivative. */
106            inline bool isA(const SubclassIdentifier<class B> identifier)
107                { return this->getIdentifier()->isA(identifier.getIdentifier()); }
108            /** @returns true if the objects class is exactly of the given type. */
109            inline bool isDirectlyA(const SubclassIdentifier<class B> identifier)
110                { return this->getIdentifier()->isDirectlyA(identifier.getIdentifier()); }
111            /** @returns true if the objects class is a child of the given type. */
112            inline bool isChildOf(const SubclassIdentifier<class B> identifier)
113                { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
114            /** @returns true if the objects class is a parent of the given type. */
115            inline bool isParentOf(const SubclassIdentifier<class B> identifier)
116                { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
117
118
119            /** @returns true if the objects class is of the given type or a derivative. */
120            inline bool isA(const OrxonoxClass* object)
121                { return this->getIdentifier()->isA(object->getIdentifier()); }
122            /** @returns true if the objects class is exactly of the given type. */
123            inline bool isDirectlyA(const OrxonoxClass* object)
124                { return this->getIdentifier()->isDirectlyA(object->getIdentifier()); }
125            /** @returns true if the objects class is a child of the given type. */
126            inline bool isChildOf(const OrxonoxClass* object)
127                { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
128            /** @returns true if the objects class is a parent of the given type. */
129            inline bool isParentOf(const OrxonoxClass* object)
130                { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
131
132
133            /** @brief Sets the name of the object. @param name The name */
134            inline virtual void setName(const std::string& name) { this->name_ = name; }
135
136            /** @returns the name of the object. */
137            inline const std::string& getName() const { return this->name_; }
138
139            /** @brief Sets the state of the objects activity. @param bActive True = active */
140            inline virtual void setActive(bool bActive) { this->bActive_ = bActive; }
141
142            /** @returns the state of the objects activity. */
143            inline const bool isActive() const { return this->bActive_; }
144
145            /** @brief Sets the state of the objects visibility. @param bVisible True = visible */
146            inline virtual void setVisible(bool bVisible) { this->bVisible_ = bVisible; }
147
148            /** @returns the state of the objects visibility. */
149            inline const bool isVisible() const { return this->bVisible_; }
150
151        private:
152            Identifier* identifier_;        //!< The Identifier of the object
153            IdentifierList* parents_;       //!< List of all parents of the object
154            MetaObjectList metaList_;       //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
155
156            std::string name_;              //!< The name of the object
157            bool bActive_;                  //!< True = the object is active
158            bool bVisible_;                 //!< True = the object is visible
159    };
160    template class _CoreExport orxonox::ClassIdentifier<OrxonoxClass>;
161    template class _CoreExport orxonox::ObjectList<OrxonoxClass>;
162}
163
164#endif /* _OrxonoxClass_H__ */
Note: See TracBrowser for help on using the repository browser.