Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added benschs Debug.h from orxonox_v1

include Debug.h or CoreIncludes.h and use it in the following way:
COUT(int) << bla;
PRINT(int)(bla);
PRINTF(int)(bla);

where 'bla' is the same as if you would use the normal std::cout or printf function
and 'int' is a value between 0 and 5:
0 = no debug output
1 = errors
2 = warnings
3 = info
4 = debug
5 = more debug

so to print a warning, use int = 2
for some unimportant debug information, use int = 4
and so on…

the level of the output is configured in the Debug.h file (later i'll add an entry to the config-file for the soft-level).

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