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
RevLine 
[365]1/**
[443]2    @file CoreIncludes.h
[447]3    @brief Definition of macros and typedefs.
[365]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
[197]13#include "Identifier.h"
[218]14#include "Factory.h"
[244]15#include "ClassFactory.h"
[221]16#include "Iterator.h"
[197]17#include "OrxonoxClass.h"
[434]18#include "ConfigValueContainer.h"
[453]19#include "Debug.h"
[219]20
[450]21#include "OgreVector2.h"
[434]22#include "OgreVector3.h"
23#include "OgreColourValue.h"
[460]24#include "OgreQuaternion.h"
25#include "OgreMatrix3.h"
[219]26
[447]27
28// Some typedefs
[434]29namespace orxonox
30{
[450]31    typedef Ogre::Vector2 Vector2;
[434]32    typedef Ogre::Vector3 Vector3;
33    typedef Ogre::ColourValue ColourValue;
[460]34    typedef Ogre::Radian Radian;
[472]35    typedef Ogre::Degree Degree;
[460]36    typedef Ogre::Real Real;
37    typedef Ogre::Quaternion Quaternion;
38    typedef Ogre::Matrix3 Matrix3;
[434]39}
40
[447]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*/
[244]47#define InternRegisterObject(ClassName, bRootClass) \
48    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
[219]49    if (Identifier::isCreatingHierarchy() && this->getParents()) \
50        this->getParents()->add(this->getIdentifier()); \
[224]51    ClassIdentifier<ClassName>::addObject(this)
[219]52
[447]53/**
54    @brief Intern macro, containing the specific part of RegisterRootObject.
55    @param ClassName The name of the class
56*/
[244]57#define InternRegisterRootObject(ClassName) \
58    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
59        this->setParents(new IdentifierList()); \
60    InternRegisterObject(ClassName, true)
[220]61
[447]62/**
63    @brief RegisterObject - with and without debug output.
64    @param ClassName The name of the class
65*/
[244]66#define RegisterObject(ClassName) \
[453]67    COUT(4) << "*** Register Object: " << #ClassName << "\n"; \
[244]68    InternRegisterObject(ClassName, false)
[219]69
[447]70/**
71    @brief RegisterRootObject - with and without debug output.
72    @param ClassName The name of the class
73*/
[244]74#define RegisterRootObject(ClassName) \
[453]75    COUT(4) << "*** Register Root-Object: " << #ClassName << "\n"; \
[244]76    InternRegisterRootObject(ClassName)
[219]77
[447]78/**
79    @brief Returns the Identifier of the given class.
80    @param ClassName The name of the class
81*/
[219]82#define Class(ClassName) \
83    ClassIdentifier<ClassName>::getIdentifier()
84
[447]85/**
86    @brief Creates the entry in the Factory.
87    @param ClassName The name of the class
88*/
[219]89#define CreateFactory(ClassName) \
[457]90    bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create(#ClassName)
[219]91
[447]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*/
[365]96#define ID(StringOrInt) \
97    Factory::getIdentifier(StringOrInt)
[434]98
[447]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*/
[434]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    } \
[450]111    varname = container##varname->getValue(varname)
Note: See TracBrowser for help on using the repository browser.