Changes between Version 4 and Version 5 of code/doc/Identifier
- Timestamp:
- Feb 24, 2008, 11:13:09 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/doc/Identifier
v4 v5 5 5 The [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. 6 6 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.7 You 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. 8 8 9 9 A 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. … … 19 19 * '''Macro''': (Include [wiki:CoreIncludes CoreIncludes.h] to use this) 20 20 * Identifier* myidentifier = Class(BaseObject); 21 * Identifier* myidentifier = ID("BaseObject"); 21 22 22 23 * '''Comparison''': … … 59 60 Class(A1B1)->isDirectChildOf(Class(BaseObject)); // returns false 60 61 Class(A1B1)->isDirectChildOf(Class(A1)); // returns true 62 63 // Assigns the Identifier of the class with name "A2" 64 std::string name = "A2"; 65 Identifier* other = ID(name); 61 66 }}} 62 67 … … 89 94 == Networking == 90 95 96 Because [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 98 The 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 100 You can retrieve the network ID of an [wiki:Identifier] with getNetworkID().[[br]] 101 You can set the network ID of an [wiki:Identifier] with setNetworkID(int). 102 103 After 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 105 Read the Wiki-page of [wiki:Factory] to get more informations about how to iterate through all [wiki:Identifier Identifiers]. 106 91 107 == Technical informations == 108 109 ---to come---