Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/CoreIncludes.h @ 3318

Last change on this file since 3318 was 3196, checked in by rgrieder, 15 years ago

Merged pch branch back to trunk.

  • Property svn:eol-style set to native
File size: 4.3 KB
RevLine 
[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
[1505]31    @brief Definition of macros for Identifier and Factory.
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 "Factory.h"
48#include "ClassFactory.h"
[3196]49#include "ObjectList.h"
[1505]50
51
52/**
53    @brief Intern macro, containing the common parts of RegisterObject and RegisterRootObject.
54    @param ClassName The name of the class
55    @param bRootClass True if the class is directly derived from OrxonoxClass
56*/
57#define InternRegisterObject(ClassName, bRootClass) \
[1747]58    this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)); \
[1505]59    if (orxonox::Identifier::isCreatingHierarchy()) \
[1747]60    { \
61        if (this->getParents()) \
62        { \
63            orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeClassHierarchy(this->getParents(), bRootClass); \
64            this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
65        } \
66        this->setConfigValues(); \
67        return; \
68    } \
69    orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this)
[1505]70
71/**
72    @brief Intern macro, containing the specific part of RegisterRootObject.
73    @param ClassName The name of the class
74*/
75#define InternRegisterRootObject(ClassName) \
76    if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents()) \
77        this->createParents(); \
78    InternRegisterObject(ClassName, true)
79
80/**
81    @brief RegisterObject - with and without debug output.
82    @param ClassName The name of the class
83*/
84#define RegisterObject(ClassName) \
85    COUT(5) << "*** Register Object: " << #ClassName << std::endl; \
86    InternRegisterObject(ClassName, false)
87
88/**
89    @brief RegisterRootObject - with and without debug output.
90    @param ClassName The name of the class
91*/
92#define RegisterRootObject(ClassName) \
93    COUT(5) << "*** Register Root-Object: " << #ClassName << std::endl; \
94    InternRegisterRootObject(ClassName)
95
96/**
[1856]97    @brief Creates the entry in the Factory.
98    @param ClassName The name of the class
99*/
100#define CreateFactory(ClassName) \
[2087]101    bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true)
[1856]102
103/**
[2087]104    @brief Creates the entry in the Factory for classes which should not be loaded through XML.
105    @param ClassName The name of the class
106*/
107#define CreateUnloadableFactory(ClassName) \
108    bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false)
109
110/**
[1505]111    @brief Returns the Identifier of the given class.
112    @param ClassName The name of the class
113*/
[1789]114#define Class(ClassName) \
[2087]115    orxonox::ClassIdentifier<ClassName>::getIdentifier()
[1505]116
117/**
[1856]118    @brief Returns the Identifier with a given name through the factory.
119    @param String The name of the class
[1505]120*/
[2087]121#define ClassByString(String) \
[1856]122    orxonox::Factory::getIdentifier(String)
[1505]123
124/**
[1856]125    @brief Returns the Identifier with a given network ID through the factory.
126    @param networkID The network ID of the class
[1505]127*/
[1856]128#define ClassByID(networkID) \
129    orxonox::Factory::getIdentifier(networkID)
[1505]130
131#endif /* _CoreIncludes_H__ */
Note: See TracBrowser for help on using the repository browser.