Orxonox: src/core/Identifier.h File Reference

# Identifier.h File Reference

Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes, implementation of the ClassIdentifier and SubclassIdentifier classes. More...

`#include "CorePrereqs.h"`
`#include <cassert>`
`#include <map>`
`#include <set>`
`#include <string>`
`#include <typeinfo>`
`#include "util/Debug.h"`
`#include "MetaObjectList.h"`
`#include "ObjectList.h"`
`#include "ObjectListBase.h"`
`#include "Super.h"`

## Namespaces

namespace | orxonox

## Classes

class | orxonox::ClassIdentifier< T >
| The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables the Identifier cannot have. More...
class | orxonox::Identifier
| The Identifier is used to identify the class of an object and to store informations about the class. More...
class | orxonox::SubclassIdentifier< T >
| The SubclassIdentifier acts almost like an Identifier, but has some prerequisites. More...

## Defines

#define | SUPER_INTRUSIVE_DECLARATION_INCLUDE

## Functions

std::ostream & | orxonox::operator<< (std::ostream &out, const std::set< const Identifier * > &list)
| Lists the names of all Identifiers in a std::set<const Identifier*>.

## Detailed Description

Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes, implementation of the ClassIdentifier and SubclassIdentifier classes.

Definition of all super-function related macros.

The Identifier contains all needed informations about the class it belongs to:

- the name
- a list with all objects
- parents and children
- the factory (if available)
- the networkID that can be synchronised with the server
- all configurable variables (if available)

Every object has a pointer to the Identifier of its class. This allows the use isA(...), isExactlyA(...), isChildOf(...) and isParentOf(...).

To create the class-hierarchy, the Identifier has some intern functions and variables.

Every Identifier is in fact a ClassIdentifier, but they are derived from Identifier.

SubclassIdentifier is a separated class, acting like an Identifier, but has a given class. You can only assign Identifiers of exactly the given class or of a derivative to a SubclassIdentifier.

This file defines all macros needed to add a new "super-function". If you add a super-function, you can call SUPER(myclass, functionname) inside your code and the function of the parentclass gets called. This is comparable with super.functionname() in Java or other languages.

This works only with virtual functions that return nothing (void) and belong to classes that have an Identifier. Arguments however are supported.

To add a new super-function, you have process 4 steps:

1) Add a new SUPER macro This allows you to call the super-function in your code. Location: This file (Super.h), marked with --> HERE <-- comments (1/3)

2) Call the SUPER_FUNCTION_GLOBAL_DECLARATION_PART1/2 macros. This defines some global classes and templates, needed to create and call the super-functions. Location: This file (Super.h), marked with --> HERE <-- comments (2/3)

3) Call the SUPER_INTRUSIVE_DECLARATION macro. This will be included into the declaration of ClassIdentifier<T>. Location: This file (Super.h), marked with --> HERE <-- comments (3/3)

4) Call the SUPER_FUNCTION macro. This defines a partially specialized template that will decide if a class is "super" to another class. If the check returns true, a SuperFunctionCaller gets created, which will be used by the SUPER macro. You have to add this into the header-file of the baseclass of the super-function (the class that first implements the function), below the class declaration. You can't call it directly in this file, because otherwise you had to include the headerfile right here, which would cause some ugly backdependencies, include loops and slower compilation. Dont forget to include Super.h in the header-file. Location: The header-file of the baseclass (Baseclass.h), below the class declaration

## Define Documentation

#define SUPER_INTRUSIVE_DECLARATION_INCLUDE