Orxonox
0.0.5 Codename: Arcturus
|
Defines several very important macros used to register objects, register classes, and to work with identifiers. More...
#include "CorePrereqs.h"
#include "util/Output.h"
#include "class/IdentifierManager.h"
#include "object/ClassFactory.h"
#include "object/ObjectList.h"
#include "module/StaticallyInitializedInstance.h"
Go to the source code of this file.
Classes | |
class | orxonox::StaticallyInitializedIdentifier |
The static initializer stores the parent classes of this identifier. More... | |
struct | orxonox::StaticallyInitializedIdentifier::InheritsFromClass< T > |
Namespaces | |
orxonox | |
Die Wagnis Klasse hat die folgenden Aufgaben: | |
Macros | |
#define | Class(ClassName) orxonox::ClassIdentifier<ClassName>::getIdentifier() |
Returns the Identifier of the given class. More... | |
#define | RegisterAbstractClass(ClassName) RegisterClassWithFactory(ClassName, static_cast<ClassFactory<ClassName>*>(nullptr), false) |
Registers an abstract class in the framework. More... | |
#define | RegisterClass(ClassName) RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), true) |
Registers the class in the framework. More... | |
#define | RegisterClassNoArgs(ClassName) RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryNoArgs<ClassName>(), true) |
Registers the class in the framework (for classes without arguments in their constructor). More... | |
#define | RegisterClassWithFactory(ClassName, FactoryInstance, bLoadable) orxonox::SI_I& _##ClassName##Identifier = (*new orxonox::SI_I(orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable))) |
Registers the class in the framework with a given Factory. More... | |
#define | RegisterObject(ClassName) |
Registers a newly created object in the framework. More... | |
#define | RegisterUnloadableClass(ClassName) RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), false) |
Registers the class in the framework (for classes which should not be loaded through XML). More... | |
Typedefs | |
typedef StaticallyInitializedIdentifier | orxonox::SI_I |
Functions | |
Identifier * | orxonox::ClassByID (uint32_t id) |
Returns the Identifier with a given network ID. More... | |
Identifier * | orxonox::ClassByLowercaseString (const std::string &name) |
Returns the Identifier with a given lowercase name. More... | |
template<class T > | |
Identifier * | orxonox::ClassByObjectType (const T *p) |
Returns the Identifier with a given 'this' pointer. More... | |
Identifier * | orxonox::ClassByString (const std::string &name) |
Returns the Identifier with a given name. More... | |
template<class T > | |
Identifier * | orxonox::registerClass (const std::string &name, ClassFactory< T > *factory, bool bLoadable=true) |
Overload of registerClass() which determines T implicitly by the template argument of the ClassFactory. More... | |
template<class T > | |
Identifier * | orxonox::registerClass (const std::string &name, Factory *factory, bool bLoadable=true) |
Registers a class in the framework. More... | |
Defines several very important macros used to register objects, register classes, and to work with identifiers.
Every class needs the RegisterObject(class)
macro in its constructor.
To register class in the class-hierarchy, use the RegisterClass(class)
macro outside of the class implementation, so it gets executed statically before main()
. If you don't want class to be loadable, but still register it, call RegisterUnloadableClass(class)
.
Abstract classes are registered with RegisterAbstractClass(class)
. For abstract classes, the inheritance must be defined manually with RegisterAbstractClass(class)
.inheritsFrom(Class(parent)). Multiple parent classes can be defined by chaining the above command.
Example:
This file also defines a number of other useful macros, like, for example, Class(class)
which returns the Identifier of class, or ClassByString
("class") which returns the Identifier of a class with name "class".
Example:
#define Class | ( | ClassName | ) | orxonox::ClassIdentifier<ClassName>::getIdentifier() |
Returns the Identifier of the given class.
ClassName | The name of the class |
#define RegisterAbstractClass | ( | ClassName | ) | RegisterClassWithFactory(ClassName, static_cast<ClassFactory<ClassName>*>(nullptr), false) |
Registers an abstract class in the framework.
Should be used in combination with inheritsFrom(base-class-identifier).
ClassName | The name of the class |
#define RegisterClass | ( | ClassName | ) | RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), true) |
Registers the class in the framework.
ClassName | The name of the class |
#define RegisterClassNoArgs | ( | ClassName | ) | RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryNoArgs<ClassName>(), true) |
Registers the class in the framework (for classes without arguments in their constructor).
ClassName | The name of the class |
#define RegisterClassWithFactory | ( | ClassName, | |
FactoryInstance, | |||
bLoadable | |||
) | orxonox::SI_I& _##ClassName##Identifier = (*new orxonox::SI_I(orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable))) |
Registers the class in the framework with a given Factory.
ClassName | The name of the class |
FactoryInstance | An instance of a factory that can create the class |
bLoadable | Whether the class is allowed to be loaded through XML |
#define RegisterObject | ( | ClassName | ) |
Registers a newly created object in the framework.
Has to be called at the beginning of the constructor of ClassName.
ClassName | The name of the class |
#define RegisterUnloadableClass | ( | ClassName | ) | RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), false) |
Registers the class in the framework (for classes which should not be loaded through XML).
ClassName | The name of the class |