Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 4 and Version 5 of code/doc/Identifier


Ignore:
Timestamp:
Feb 24, 2008, 11:13:09 PM (17 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/Identifier

    v4 v5  
    55The [wiki:Identifier] is a construct to identify the class of an object. All classes derived from OrxonoxClass have an Identifier, representing the class in the running game. The Identifier additionally stores all objects of its class in a [wiki:ObjectList list], knows the name of the class, can have a [wiki:ClassFactory], knows all parents and children, stores [wiki:ConfigValueContainer config-values] and shell-functions and provides several other functionalities.
    66
    7 You can get the Identifier of a given class with the macro Class(classname). You have to include [wiki:CoreIncludes CoreIncludes.h] to use it.
     7You can get the Identifier of a given class with the macro Class(classname). If you only know the string, so if the class isn't hardcoded, use the macro ID("classname"). You have to include [wiki:CoreIncludes CoreIncludes.h] to use the macros.
    88
    99A new class that wants an Identifier must use a macro (!RegisterObject(classname) or !RegisterRootObject(interfacename)) from [wiki:CoreIncludes]. Read the related Wiki-page for more informations.
     
    1919 * '''Macro''': (Include [wiki:CoreIncludes CoreIncludes.h] to use this)
    2020   * Identifier* myidentifier = Class(BaseObject);
     21   * Identifier* myidentifier = ID("BaseObject");
    2122
    2223 * '''Comparison''':
     
    5960Class(A1B1)->isDirectChildOf(Class(BaseObject)); // returns false
    6061Class(A1B1)->isDirectChildOf(Class(A1));         // returns true
     62
     63// Assigns the Identifier of the class with name "A2"
     64std::string name = "A2";
     65Identifier* other = ID(name);
    6166}}}
    6267
     
    8994== Networking ==
    9095
     96Because [wiki:Identifier Identifiers] use pointers, they are not qualified for networking. It's possible to just send the classname and use the [wiki:Factory], but this is expensive. That's why there's a network ID.
     97
     98The network ID is an unsigned integer. You can retrieve an [wiki:Identifier] with a given network ID by using the macro ID(int) (include [wiki:CoreIncludes CoreIncludes.h] to use it). It's not determined which network ID belongs to which Identifier. This changes from version to version and from system to system, depending on the number of existing classes and the code executed before main(). So ID(5) might be different on each client. That's why the server has to synchronize the network ID's.
     99
     100You can retrieve the network ID of an [wiki:Identifier] with getNetworkID().[[br]]
     101You can set the network ID of an [wiki:Identifier] with setNetworkID(int).
     102
     103After changing the network ID of an Identifier to ''newid'', there might be two Identifiers with the ID ''newid''. ID(''newid'') will then return the changed Identifier and not the old one.
     104
     105Read the Wiki-page of [wiki:Factory] to get more informations about how to iterate through all [wiki:Identifier Identifiers].
     106
    91107== Technical informations ==
     108
     109---to come---