Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 447 was 447, checked in by landauf, 16 years ago
  • added comments and doxygen-tags to the ConfigValueContainer
  • changed some comments in the other files
File size: 3.8 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"
[219]19
[434]20#include "OgreVector3.h"
21#include "OgreColourValue.h"
[219]22
[447]23
24// Some typedefs
[434]25namespace orxonox
26{
27    typedef Ogre::Vector3 Vector3;
28    typedef Ogre::ColourValue ColourValue;
29}
30
[447]31
32/**
33    @brief Intern macro, containing the common parts of RegisterObject and RegisterRootObject.
34    @param ClassName The name of the class
35    @param bRootClass True if the class is directly derived from OrxonoxClass
36*/
[244]37#define InternRegisterObject(ClassName, bRootClass) \
38    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
[219]39    if (Identifier::isCreatingHierarchy() && this->getParents()) \
40        this->getParents()->add(this->getIdentifier()); \
[224]41    ClassIdentifier<ClassName>::addObject(this)
[219]42
[447]43/**
44    @brief Intern macro, containing the specific part of RegisterRootObject.
45    @param ClassName The name of the class
46*/
[244]47#define InternRegisterRootObject(ClassName) \
48    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
49        this->setParents(new IdentifierList()); \
50    InternRegisterObject(ClassName, true)
[220]51
[447]52/**
53    @brief RegisterObject - with and without debug output.
54    @param ClassName The name of the class
55*/
[231]56#if HIERARCHY_VERBOSE
[244]57#define RegisterObject(ClassName) \
[219]58    std::cout << "*** Register Object: " << #ClassName << "\n"; \
[244]59    InternRegisterObject(ClassName, false)
[231]60#else
[244]61#define RegisterObject(ClassName) \
62    InternRegisterObject(ClassName, false)
[231]63#endif
[219]64
[447]65/**
66    @brief RegisterRootObject - with and without debug output.
67    @param ClassName The name of the class
68*/
[231]69#if HIERARCHY_VERBOSE
[244]70#define RegisterRootObject(ClassName) \
71    std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
72    InternRegisterRootObject(ClassName)
[231]73#else
[244]74#define RegisterRootObject(ClassName) \
75    InternRegisterRootObject(ClassName)
[231]76#endif
[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) \
[244]90    bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create()
[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    } \
111    this->varname = container##varname->getValue(varname)
Note: See TracBrowser for help on using the repository browser.