Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

first try to add a WorldEntity. at the moment it's just a class with an Ogre::SceneNode

File size: 3.8 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::Real Real;
36    typedef Ogre::Quaternion Quaternion;
37    typedef Ogre::Matrix3 Matrix3;
38}
39
40
41/**
42    @brief Intern macro, containing the common parts of RegisterObject and RegisterRootObject.
43    @param ClassName The name of the class
44    @param bRootClass True if the class is directly derived from OrxonoxClass
45*/
46#define InternRegisterObject(ClassName, bRootClass) \
47    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
48    if (Identifier::isCreatingHierarchy() && this->getParents()) \
49        this->getParents()->add(this->getIdentifier()); \
50    ClassIdentifier<ClassName>::addObject(this)
51
52/**
53    @brief Intern macro, containing the specific part of RegisterRootObject.
54    @param ClassName The name of the class
55*/
56#define InternRegisterRootObject(ClassName) \
57    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
58        this->setParents(new IdentifierList()); \
59    InternRegisterObject(ClassName, true)
60
61/**
62    @brief RegisterObject - with and without debug output.
63    @param ClassName The name of the class
64*/
65#define RegisterObject(ClassName) \
66    COUT(4) << "*** Register Object: " << #ClassName << "\n"; \
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) \
74    COUT(4) << "*** Register Root-Object: " << #ClassName << "\n"; \
75    InternRegisterRootObject(ClassName)
76
77/**
78    @brief Returns the Identifier of the given class.
79    @param ClassName The name of the class
80*/
81#define Class(ClassName) \
82    ClassIdentifier<ClassName>::getIdentifier()
83
84/**
85    @brief Creates the entry in the Factory.
86    @param ClassName The name of the class
87*/
88#define CreateFactory(ClassName) \
89    bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create(#ClassName)
90
91/**
92    @brief Returns the Identifier with either a given name or a given network ID through the factory.
93    @param StringOrInt The name or the network ID of the class
94*/
95#define ID(StringOrInt) \
96    Factory::getIdentifier(StringOrInt)
97
98/**
99    @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file).
100    @param varname The name of the variable
101    @param defvalue The default-value of the variable
102*/
103#define SetConfigValue(varname, defvalue) \
104    ConfigValueContainer* container##varname = this->getIdentifier()->getConfigValueContainer(#varname); \
105    if (!container##varname) \
106    { \
107        container##varname = new ConfigValueContainer(this->getIdentifier()->getName(), #varname, defvalue); \
108        this->getIdentifier()->setConfigValueContainer(#varname, container##varname); \
109    } \
110    varname = container##varname->getValue(varname)
Note: See TracBrowser for help on using the repository browser.