Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

CoreIncludes

TracNav(TracNav/TOC_Development)?

Description

CoreIncludes.h is a header-file in the core library, declaring several macros for Identifiers and the Factory.

Macros

Object Registration

  • RegisterObject(ClassName): This macro is used by classes that want to have an Identifier. Use the macro at the beginning of the constructor. It adds new instances of this class to the corresponding ObjectListBase and helps building the class hierarchy.
  • RegisterRootObject(ClassName): This is the same as RegisterObject(ClassName), but for root-classes like Interfaces (Tickable, network/Synchronisable and others) and the BaseObject.

Factory

  • CreateFactory(ClassName): Creates the entry in the Factory for the given class and adds a ClassFactory to the corresponding Identifier. This macro has to be used outside the class-functions as a static call (preferably just before the constructor).

Identifiers

  • Class(ClassName): Returns the ClassIdentifier of the given class.
  • ClassByString(String): Returns the Identifier of the class with the given name if the entry in the Factory exists
  • ClassByID(NetworkID): Returns the Identifier of the class with the given networkID if the entry in the Factory exists

Examples

// Create the factory for MyClass
CreateFactory(MyClass);

// Constructor:
MyClass::MyClass()
{
    // Register the object in the Identifier of MyClass
    RegisterObject(MyClass);
}
// Assigns the Identifier of MyClass
Identifier* identifier = Class(MyClass);
// Assigns the Identifier of a class named "MyClass"
Identifier* identifier = ClassByName("MyClass");