[1505] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
[2171] | 30 | @file |
---|
[6038] | 31 | @brief Definition of macros for Identifiers |
---|
[1505] | 32 | |
---|
| 33 | Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface |
---|
| 34 | or the BaseObject itself, it needs the macro RegisterRootObject(class) instead. |
---|
| 35 | |
---|
| 36 | To allow the object being created through the factory, use the CreateFactory(class) macro outside |
---|
| 37 | the of the class implementation, so it gets executed before main(). |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #ifndef _CoreIncludes_H__ |
---|
| 41 | #define _CoreIncludes_H__ |
---|
| 42 | |
---|
| 43 | #include "CorePrereqs.h" |
---|
| 44 | |
---|
[3196] | 45 | #include "util/Debug.h" |
---|
[1505] | 46 | #include "Identifier.h" |
---|
| 47 | #include "ClassFactory.h" |
---|
[3196] | 48 | #include "ObjectList.h" |
---|
[1505] | 49 | |
---|
| 50 | |
---|
| 51 | /** |
---|
| 52 | @brief Intern macro, containing the common parts of RegisterObject and RegisterRootObject. |
---|
| 53 | @param ClassName The name of the class |
---|
| 54 | @param bRootClass True if the class is directly derived from OrxonoxClass |
---|
| 55 | */ |
---|
| 56 | #define InternRegisterObject(ClassName, bRootClass) \ |
---|
[3325] | 57 | if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initialiseObject(this, #ClassName, bRootClass)) \ |
---|
[1747] | 58 | return; \ |
---|
[3325] | 59 | else \ |
---|
| 60 | ((void)0) |
---|
[1505] | 61 | |
---|
| 62 | /** |
---|
| 63 | @brief RegisterObject - with and without debug output. |
---|
| 64 | @param ClassName The name of the class |
---|
| 65 | */ |
---|
| 66 | #define RegisterObject(ClassName) \ |
---|
| 67 | InternRegisterObject(ClassName, false) |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | @brief RegisterRootObject - with and without debug output. |
---|
| 71 | @param ClassName The name of the class |
---|
| 72 | */ |
---|
| 73 | #define RegisterRootObject(ClassName) \ |
---|
[3325] | 74 | InternRegisterObject(ClassName, true) |
---|
[1505] | 75 | |
---|
| 76 | /** |
---|
[6038] | 77 | @brief Creates the Factory. |
---|
[1856] | 78 | @param ClassName The name of the class |
---|
| 79 | */ |
---|
| 80 | #define CreateFactory(ClassName) \ |
---|
[6038] | 81 | Factory* _##ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName) |
---|
[1856] | 82 | |
---|
| 83 | /** |
---|
[1505] | 84 | @brief Returns the Identifier of the given class. |
---|
| 85 | @param ClassName The name of the class |
---|
| 86 | */ |
---|
[1789] | 87 | #define Class(ClassName) \ |
---|
[2087] | 88 | orxonox::ClassIdentifier<ClassName>::getIdentifier() |
---|
[1505] | 89 | |
---|
| 90 | |
---|
[3325] | 91 | namespace orxonox |
---|
| 92 | { |
---|
| 93 | /** |
---|
[6038] | 94 | @brief Returns the Identifier with a given name. |
---|
[3325] | 95 | @param String The name of the class |
---|
| 96 | */ |
---|
| 97 | inline Identifier* ClassByString(const std::string& name) |
---|
| 98 | { |
---|
[6038] | 99 | return Identifier::getIdentifierByString(name); |
---|
[3325] | 100 | } |
---|
[1505] | 101 | |
---|
[3325] | 102 | /** |
---|
[6038] | 103 | @brief Returns the Identifier with a given lowercase name. |
---|
| 104 | @param String The lowercase name of the class |
---|
[3325] | 105 | */ |
---|
[6038] | 106 | inline Identifier* ClassByLowercaseString(const std::string& name) |
---|
[3325] | 107 | { |
---|
[6038] | 108 | return Identifier::getIdentifierByLowercaseString(name); |
---|
[3325] | 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
[1505] | 112 | #endif /* _CoreIncludes_H__ */ |
---|