Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 10 and Version 11 of code/doc/CoreIncludes


Ignore:
Timestamp:
Sep 29, 2008, 3:01:55 AM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/CoreIncludes

    v10 v11  
    44== Description ==
    55
    6 [wiki:CoreIncludes CoreIncludes.h] is a header-file, declaring several easy-to-use macros providing functionalities of the [wiki:Core core library] like [wiki:Identifier Identifiers], the [wiki:Factory], [wiki:ConfigValueContainer config-values] and others.
     6!CoreIncludes.h is a header-file in the [wiki:Core core library], declaring several macros for [wiki:Identifier Identifiers] and the [wiki:Factory].
    77
    88== Macros ==
    99
    10  * '''Identifier''':
    11    * '''!RegisterObject('''''!ClassName''''')''': This macro is used by classes that want to have an [wiki:Identifier]. Use the macro at the beginning of the constructor. It adds new objects of this class to the corresponding [wiki:ObjectList] and helps building up the [wiki:Identifier class hierarchy].
    12    * '''!RegisterRootObject('''''!ClassName''''')''': This is the same as !RegisterObject(!ClassName), but for root-classes like Interfaces ([wiki:Tickable], [wiki:Synchronisable] and others) and the [wiki:BaseObject].
    13    * '''Class('''''!ClassName''''')''': Returns the [wiki:ClassIdentifier] of the given class.
     10=== Object Registration ===
     11 * '''!RegisterObject('''''!ClassName''''')''': This macro is used by classes that want to have an [wiki:Identifier]. Use the macro at the beginning of the constructor. It adds new instances of this class to the corresponding [wiki:ObjectListBase] and helps building the [wiki:Identifier class hierarchy].
     12 * '''!RegisterRootObject('''''!ClassName''''')''': This is the same as !RegisterObject(!ClassName), but for root-classes like Interfaces ([wiki:Tickable], [wiki:network/Synchronisable] and others) and the [wiki:BaseObject].
    1413
    15  * '''Factory''':
    16    * '''!CreateFactory('''''!ClassName''''')''': Creates the entry in the [wiki:Factory] for the given class and adds a [wiki:ClassFactory] to the corresponding [wiki:Identifier]. This macro has to be used outside the class-functions as a static call.
    17    * '''ID('''''!StringOrInt''''')''': Returns the [wiki:Identifier] of the class with the given name or the given network ID if the entry in the [wiki:Factory] exists (see !CreateFactory(!ClassName)).
     14=== Factory ===
     15 * '''!CreateFactory('''''!ClassName''''')''': Creates the entry in the [wiki:Factory] for the given class and adds a [wiki:ClassFactory] to the corresponding [wiki:Identifier]. This macro has to be used outside the class-functions as a static call (preferably just before the constructor).
    1816
    19  * '''Config-values''':
    20    * '''!SetConfigValue('''''varname''''', '''''defvalue''''')''': Defines a [wiki:ConfigValueContainer configurable] variable with a default value that can be changed in the config-file. ''varname'' must be a member-variable of a class and the macro should only be used in the setConfigValues() function of this class to allow ingame-changes of the values. Read the Wiki-page of [wiki:ConfigValueContainer] for further information.
    21    * '''!ResetConfigValue('''''varname''''')''': Sets the given config-value back to the default value (see !SetConfigValue(varname, defvalue)).
     17=== Identifiers ===
     18 * '''Class('''''!ClassName''''')''': Returns the [wiki:ClassIdentifier] of the given class.
     19 * '''ClassByString('''''String''''')''': Returns the [wiki:Identifier] of the class with the given name if the entry in the [wiki:Factory] exists
     20 * '''ClassByID('''''NetworkID''''')''': Returns the [wiki:Identifier] of the class with the given networkID if the entry in the [wiki:Factory] exists
     21
     22== Examples ==
     23
     24{{{
     25// Create the factory for MyClass
     26CreateFactory(MyClass);
     27
     28// Constructor:
     29MyClass::MyClass()
     30{
     31    // Register the object in the Identifier of MyClass
     32    RegisterObject(MyClass);
     33}
     34}}}
     35
     36{{{
     37// Assigns the Identifier of MyClass
     38Identifier* identifier = Class(MyClass);
     39}}}
     40
     41{{{
     42// Assigns the Identifier of a class named "MyClass"
     43Identifier* identifier = ClassByName("MyClass");
     44}}}