Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

copied changed files from objecthierarchy-branch

File size: 2.4 KB
RevLine 
[384]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
[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"
[219]18
19
[384]20// Intern macro, containing the common parts of RegisterObject and RegisterRootObject
[244]21#define InternRegisterObject(ClassName, bRootClass) \
22    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
[219]23    if (Identifier::isCreatingHierarchy() && this->getParents()) \
24        this->getParents()->add(this->getIdentifier()); \
[224]25    ClassIdentifier<ClassName>::addObject(this)
[219]26
[384]27// Intern macro, containing the specific part of RegisterRootObject
[244]28#define InternRegisterRootObject(ClassName) \
29    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
30        this->setParents(new IdentifierList()); \
31    InternRegisterObject(ClassName, true)
[220]32
[384]33// RegisterObject - with and without debug output
[231]34#if HIERARCHY_VERBOSE
[244]35#define RegisterObject(ClassName) \
[219]36    std::cout << "*** Register Object: " << #ClassName << "\n"; \
[244]37    InternRegisterObject(ClassName, false)
[231]38#else
[244]39#define RegisterObject(ClassName) \
40    InternRegisterObject(ClassName, false)
[231]41#endif
[219]42
[384]43// RegisterRootObject - with and without debug output
[231]44#if HIERARCHY_VERBOSE
[244]45#define RegisterRootObject(ClassName) \
46    std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
47    InternRegisterRootObject(ClassName)
[231]48#else
[244]49#define RegisterRootObject(ClassName) \
50    InternRegisterRootObject(ClassName)
[231]51#endif
[219]52
[384]53// Class(ClassName) returns the Identifier of the given class
[219]54#define Class(ClassName) \
55    ClassIdentifier<ClassName>::getIdentifier()
56
[384]57// Creates the entry in the Factory
[219]58#define CreateFactory(ClassName) \
[244]59    bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create()
[219]60
[384]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.