Changes between Version 2 and Version 3 of code/doc/Identifier
- Timestamp:
- Feb 24, 2008, 10:52:42 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/doc/Identifier
v2 v3 4 4 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 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. 6 8 7 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. … … 14 16 15 17 == Functions == 18 19 * '''Macro''': (Include [wiki:CoreIncludes CoreIncludes.h] to use this) 20 * Identifier* myidentifier = Class(BaseObject); 16 21 17 22 * '''Comparison''': … … 37 42 == Examples == 38 43 44 The following examples use the class-tree below. 45 46 {{{ 47 #!cpp 48 Identifier* myidentifier = Class(A1); // Assigns the Identifier of A1 49 50 myidentifier->isA(Class(BaseObject)); // returns true 51 myidentifier->isA(Class(A1)); // returns true 52 myidentifier->isA(Class(A1B1)); // returns false 53 myidentifier->isA(Class(A2)); // returns false 54 Class(A3)->isA(Class(Interface1)); // returns true 55 56 Class(A1B1)->isChildOf(Class(BaseObject)); // returns true 57 Class(A1B1)->isChildOf(Class(A1)); // returns true 58 59 Class(A1B1)->isDirectChildOf(Class(BaseObject)); // returns false 60 Class(A1B1)->isDirectChildOf(Class(A1)); // returns true 61 }}} 62 63 {{{ 64 #!cpp 65 // Creates a new instance of A1 66 BaseObject* newobject = Class(A1)->fabricate(); 67 68 // Creates a new instance of A1 and casts it to Interface1 69 Identifier* myidentifier = Class(A3); 70 Interface1* newobject = (Interface1)(myidentifier->fabricate()); 71 }}} 72 73 {{{ 74 #!cpp 75 Identifier* myidentifier = Class(BaseObject); 76 for (std::list<const Identifier*>::const_iterator it = myidentifier->getDirectParentsBegin(); it != myidentifier->getDirectParentsEnd(); ++it) 77 cout << (*it)->getName() << std::endl; 78 79 /* 80 returns: 81 A1 82 A2 83 A3 84 */ 85 }}} 86 87 [[Image(Core:testclass_interface_tree.gif)]] 88 39 89 == Networking == 40 90