Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 813 was 813, checked in by landauf, 16 years ago
  • removed IdentifierList and replaced it by a std::list
  • changed several doxygen tags
File size: 8.9 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 <list>
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::list<const Identifier*>* getParents() const { return this->parents_; }
70
71            /** @brief Creates the parents-list. */
72            inline void createParents() { this->parents_ = new std::list<const Identifier*>(); }
73
74//            /** @brief Sets the Parents of the object. Used by the RegisterObject-macro. */
75//            inline void setParents(std::list<const Identifier*>* parents) { this->parents_ = parents; }
76
77            /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */
78            inline MetaObjectList& getMetaList() { return this->metaList_; }
79
80
81            /** @brief Returns true if the objects class is of the given type or a derivative. */
82            inline bool isA(const Identifier* identifier)
83                { return this->getIdentifier()->isA(identifier); }
84            /** @brief Returns true if the objects class is exactly of the given type. */
85            inline bool isDirectlyA(const Identifier* identifier)
86                { return this->getIdentifier()->isDirectlyA(identifier); }
87            /** @brief Returns true if the objects class is a child of the given type. */
88            inline bool isChildOf(const Identifier* identifier)
89                { return this->getIdentifier()->isChildOf(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
94
95            /** @brief Returns true if the objects class is of the given type or a derivative. */
96            inline bool isA(const SubclassIdentifier<class B>* identifier)
97                { return this->getIdentifier()->isA(identifier->getIdentifier()); }
98            /** @brief Returns true if the objects class is exactly of the given type. */
99            inline bool isDirectlyA(const SubclassIdentifier<class B>* identifier)
100                { return this->getIdentifier()->isDirectlyA(identifier->getIdentifier()); }
101            /** @brief Returns true if the objects class is a child of the given type. */
102            inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
103                { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
104            /** @brief Returns true if the objects class is a parent of the given type. */
105            inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
106                { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
107
108
109            /** @brief Returns true if the objects class is of the given type or a derivative. */
110            inline bool isA(const SubclassIdentifier<class B> identifier)
111                { return this->getIdentifier()->isA(identifier.getIdentifier()); }
112            /** @brief Returns true if the objects class is exactly of the given type. */
113            inline bool isDirectlyA(const SubclassIdentifier<class B> identifier)
114                { return this->getIdentifier()->isDirectlyA(identifier.getIdentifier()); }
115            /** @brief Returns true if the objects class is a child of the given type. */
116            inline bool isChildOf(const SubclassIdentifier<class B> identifier)
117                { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
118            /** @brief Returns true if the objects class is a parent of the given type. */
119            inline bool isParentOf(const SubclassIdentifier<class B> identifier)
120                { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
121
122
123            /** @brief Returns true if the objects class is of the given type or a derivative. */
124            inline bool isA(const OrxonoxClass* object)
125                { return this->getIdentifier()->isA(object->getIdentifier()); }
126            /** @brief Returns true if the objects class is exactly of the given type. */
127            inline bool isDirectlyA(const OrxonoxClass* object)
128                { return this->getIdentifier()->isDirectlyA(object->getIdentifier()); }
129            /** @brief Returns true if the objects class is a child of the given type. */
130            inline bool isChildOf(const OrxonoxClass* object)
131                { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
132            /** @brief Returns true if the objects class is a parent of the given type. */
133            inline bool isParentOf(const OrxonoxClass* object)
134                { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
135
136
137            /** @brief Sets the name of the object. @param name The name */
138            inline virtual void setName(const std::string& name) { this->name_ = name; }
139
140            /** @brief Returns the name of the object. @return The name */
141            inline const std::string& getName() const { return this->name_; }
142
143            /** @brief Sets the state of the objects activity. @param bActive True = active */
144            inline virtual void setActive(bool bActive) { this->bActive_ = bActive; }
145
146            /** @brief Returns the state of the objects activity. @return The state of the activity */
147            inline const bool isActive() const { return this->bActive_; }
148
149            /** @brief Sets the state of the objects visibility. @param bVisible True = visible */
150            inline virtual void setVisible(bool bVisible) { this->bVisible_ = bVisible; }
151
152            /** @brief Returns the state of the objects visibility. @return The state of the visibility */
153            inline const bool isVisible() const { return this->bVisible_; }
154
155        private:
156            Identifier* identifier_;                    //!< The Identifier of the object
157            std::list<const Identifier*>* parents_;     //!< List of all parents of the object
158            MetaObjectList metaList_;                   //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
159
160            std::string name_;                          //!< The name of the object
161            bool bActive_;                              //!< True = the object is active
162            bool bVisible_;                             //!< True = the object is visible
163    };
164    template class _CoreExport orxonox::ClassIdentifier<OrxonoxClass>;
165    template class _CoreExport orxonox::ObjectList<OrxonoxClass>;
166}
167
168#endif /* _OrxonoxClass_H__ */
Note: See TracBrowser for help on using the repository browser.