Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/core/IdentifierIncludes.h @ 473

Last change on this file since 473 was 384, checked in by landauf, 17 years ago

copied changed files from objecthierarchy-branch

File size: 2.4 KB
Line 
1/**
2    @file IDentifierIncludes.h
3    @brief Definition of macros for the class-hierarchy and the factory.
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
19
20// Intern macro, containing the common parts of RegisterObject and RegisterRootObject
21#define InternRegisterObject(ClassName, bRootClass) \
22    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
23    if (Identifier::isCreatingHierarchy() && this->getParents()) \
24        this->getParents()->add(this->getIdentifier()); \
25    ClassIdentifier<ClassName>::addObject(this)
26
27// Intern macro, containing the specific part of RegisterRootObject
28#define InternRegisterRootObject(ClassName) \
29    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
30        this->setParents(new IdentifierList()); \
31    InternRegisterObject(ClassName, true)
32
33// RegisterObject - with and without debug output
34#if HIERARCHY_VERBOSE
35#define RegisterObject(ClassName) \
36    std::cout << "*** Register Object: " << #ClassName << "\n"; \
37    InternRegisterObject(ClassName, false)
38#else
39#define RegisterObject(ClassName) \
40    InternRegisterObject(ClassName, false)
41#endif
42
43// RegisterRootObject - with and without debug output
44#if HIERARCHY_VERBOSE
45#define RegisterRootObject(ClassName) \
46    std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
47    InternRegisterRootObject(ClassName)
48#else
49#define RegisterRootObject(ClassName) \
50    InternRegisterRootObject(ClassName)
51#endif
52
53// Class(ClassName) returns the Identifier of the given class
54#define Class(ClassName) \
55    ClassIdentifier<ClassName>::getIdentifier()
56
57// Creates the entry in the Factory
58#define CreateFactory(ClassName) \
59    bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create()
60
61// ID(StringOrInt) returns the Identifier with either a given name or a given NetworkID through the factory
62#define ID(StringOrInt) \
63    Factory::getIdentifier(StringOrInt)
Note: See TracBrowser for help on using the repository browser.