Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 7 (modified by landauf, 16 years ago) (diff)

ClassIdentifier

TracNav(TracNav/TOC_Development)?


Important: The ClassIdentifier is derived from Identifier. Read the related Wiki-page to learn about all inherited features and functions.


Description

The ClassIdentifier is a template?, inherited from Identifier, containing all class-specific functions for the class represented by the Identifier. In fact this is only the ObjectList.

The constructor of ClassIdentifier is private. Only IdentifierDistributor? is allowed to create and distribute new instances. (In fact only one instance per template?-class. This is very important.)

You can't access the ClassIdentifier of a class directly. Use ClassManager?<ClassName>::getIdentifier() instead. A shorter version of this command is the macro Class(classname) (include CoreIncludes.h to use it) that returns the ClassIdentifier of the given class.

The ObjectList

Every class that uses the RegisterObject(classname) or RegisterRootObject(interfacename) macro (see CoreIncludes) is represented by an Identifier, that stores all objects of this class (and of all inherited classes) in a ObjectList. The object gets removed from the list if it gets deleted. This is handled by the destructor of OrxonoxClass and the MetaObjectList.

You can iterate through all objects in a ObjectList by using an Iterator. Read the related Wiki-page to get more informations.

Example

MyClass.h:

class MyClass : public BaseObject
{
  MyClass();
};

MyClass.cc:

#include "CoreIncludes.h"
#include "MyClass.h"

MyClass::MyClass()
{
  RegisterObject(MyClass);
}
SomeOtherFile.cc:

#include "CoreIncludes.h"
#include "MyClass.h"

Identifier* myidentifier = Class(MyClass);
std::cout << myidentifier->getName() << std::endl;

/*
returns:
MyClass
*/