Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/core/CoreIncludes.h @ 674

Last change on this file since 674 was 670, checked in by landauf, 16 years ago

copyright notes

File size: 4.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 CoreIncludes.h
30    @brief Definition of macros and typedefs.
31
32    Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface
33    or the BaseObject itself, it needs the macro RegisterRootObject(class) instead.
34
35    To allow the object being created through the factory, use the CreateFactory(class) macro outside
36    the of the class implementation, so it gets executed before main().
37*/
38
39// All needed header-files
40#include "Identifier.h"
41#include "Factory.h"
42#include "ClassFactory.h"
43#include "Iterator.h"
44#include "OrxonoxClass.h"
45#include "ConfigValueContainer.h"
46#include "Debug.h"
47
48#include "OgreVector2.h"
49#include "OgreVector3.h"
50#include "OgreColourValue.h"
51#include "OgreQuaternion.h"
52#include "OgreMatrix3.h"
53
54
55// Some typedefs
56namespace orxonox
57{
58    typedef Ogre::Vector2 Vector2;
59    typedef Ogre::Vector3 Vector3;
60    typedef Ogre::ColourValue ColourValue;
61    typedef Ogre::Radian Radian;
62    typedef Ogre::Degree Degree;
63    typedef Ogre::Real Real;
64    typedef Ogre::Quaternion Quaternion;
65    typedef Ogre::Matrix3 Matrix3;
66}
67
68
69/**
70    @brief Intern macro, containing the common parts of RegisterObject and RegisterRootObject.
71    @param ClassName The name of the class
72    @param bRootClass True if the class is directly derived from OrxonoxClass
73*/
74#define InternRegisterObject(ClassName, bRootClass) \
75    this->setIdentifier(orxonox::ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
76    if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) \
77        this->getParents()->add(this->getIdentifier()); \
78    orxonox::ClassIdentifier<ClassName>::addObject(this)
79
80/**
81    @brief Intern macro, containing the specific part of RegisterRootObject.
82    @param ClassName The name of the class
83*/
84#define InternRegisterRootObject(ClassName) \
85    if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents()) \
86        this->setParents(new orxonox::IdentifierList()); \
87    InternRegisterObject(ClassName, true)
88
89/**
90    @brief RegisterObject - with and without debug output.
91    @param ClassName The name of the class
92*/
93#define RegisterObject(ClassName) \
94    COUT(4) << "*** Register Object: " << #ClassName << "\n"; \
95    InternRegisterObject(ClassName, false)
96
97/**
98    @brief RegisterRootObject - with and without debug output.
99    @param ClassName The name of the class
100*/
101#define RegisterRootObject(ClassName) \
102    COUT(4) << "*** Register Root-Object: " << #ClassName << "\n"; \
103    InternRegisterRootObject(ClassName)
104
105/**
106    @brief Returns the Identifier of the given class.
107    @param ClassName The name of the class
108*/
109#define Class(ClassName) \
110    ClassIdentifier<ClassName>::getIdentifier()
111
112/**
113    @brief Creates the entry in the Factory.
114    @param ClassName The name of the class
115*/
116#define CreateFactory(ClassName) \
117    bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName)
118
119/**
120    @brief Returns the Identifier with either a given name or a given network ID through the factory.
121    @param StringOrInt The name or the network ID of the class
122*/
123#define ID(StringOrInt) \
124    orxonox::Factory::getIdentifier(StringOrInt)
125
126/**
127    @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file).
128    @param varname The name of the variable
129    @param defvalue The default-value of the variable
130*/
131#define SetConfigValue(varname, defvalue) \
132    orxonox::ConfigValueContainer* container##varname = this->getIdentifier()->getConfigValueContainer(#varname); \
133    if (!container##varname) \
134    { \
135        container##varname = new orxonox::ConfigValueContainer(this->getIdentifier()->getName(), #varname, varname = defvalue); \
136        this->getIdentifier()->setConfigValueContainer(#varname, container##varname); \
137    } \
138    varname = container##varname->getValue(varname)
Note: See TracBrowser for help on using the repository browser.