Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/core/CoreIncludes.h @ 472

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

added acceleration, rotationRate and momentum

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