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
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
20#include "OgreVector3.h"
21#include "OgreColourValue.h"
22
23
24// Some typedefs
25namespace orxonox
26{
27    typedef Ogre::Vector3 Vector3;
28    typedef Ogre::ColourValue ColourValue;
29}
30
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*/
37#define InternRegisterObject(ClassName, bRootClass) \
38    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
39    if (Identifier::isCreatingHierarchy() && this->getParents()) \
40        this->getParents()->add(this->getIdentifier()); \
41    ClassIdentifier<ClassName>::addObject(this)
42
43/**
44    @brief Intern macro, containing the specific part of RegisterRootObject.
45    @param ClassName The name of the class
46*/
47#define InternRegisterRootObject(ClassName) \
48    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
49        this->setParents(new IdentifierList()); \
50    InternRegisterObject(ClassName, true)
51
52/**
53    @brief RegisterObject - with and without debug output.
54    @param ClassName The name of the class
55*/
56#if HIERARCHY_VERBOSE
57#define RegisterObject(ClassName) \
58    std::cout << "*** Register Object: " << #ClassName << "\n"; \
59    InternRegisterObject(ClassName, false)
60#else
61#define RegisterObject(ClassName) \
62    InternRegisterObject(ClassName, false)
63#endif
64
65/**
66    @brief RegisterRootObject - with and without debug output.
67    @param ClassName The name of the class
68*/
69#if HIERARCHY_VERBOSE
70#define RegisterRootObject(ClassName) \
71    std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
72    InternRegisterRootObject(ClassName)
73#else
74#define RegisterRootObject(ClassName) \
75    InternRegisterRootObject(ClassName)
76#endif
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()
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    this->varname = container##varname->getValue(varname)
Note: See TracBrowser for help on using the repository browser.