Changes between Version 2 and Version 3 of code/doc/ClassIdentifier
- Timestamp:
- Feb 24, 2008, 11:58:21 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/doc/ClassIdentifier
v2 v3 7 7 The constructor of ClassIdentifier is private. Only [wiki:IdentifierDistributor] is allowed to create and distribute new instances. (In fact only '''one''' instance per template-class. This is '''very''' important.) 8 8 9 You can't access the ClassIdentifier of a class directly. Use [wiki:ClassManager]<!ClassName>::getIdentifier() instead.[[br]] The macro Class(classname) (include [wiki:CoreIncludes CoreIncludes.h] to use it) returns the ClassIdentifier of the given class. In fact this is only an abbreviation of ClassManager<!ClassName>::getIdentifier(). 9 You can't access the ClassIdentifier of a class directly. Use [wiki:ClassManager]<!ClassName>::getIdentifier() instead. A shorter version of this command is the macro Class(classname) (include [wiki:CoreIncludes CoreIncludes.h] to use it) that returns the ClassIdentifier of the given class. 10 11 == The !ObjectList == 10 12 11 13 Every class that uses the !RegisterObject(classname) or !RegisterRootObject(interfacename) macro (see [wiki:CoreIncludes]) is represented by an [wiki:Identifier], that stores all objects of this class (and of all inherited classes) in a [wiki:ObjectList]. The object gets removed from the list if it gets deleted. This is handled by the destructor of [wiki:OrxonoxClass] and the [wiki:MetaObjectList]. 12 14 13 15 You can iterate through all objects in a [wiki:ObjectList] by using an [wiki:Iterator]. Read the related Wiki-page to get more informations. 16 17 == Example == 18 19 {{{ 20 #!cpp 21 MyClass.h: 22 23 class MyClass : public BaseObject 24 { 25 MyClass(); 26 }; 27 28 }}} 29 30 {{{ 31 #!cpp 32 MyClass.cc: 33 34 #include "CoreIncludes.h" 35 #include "MyClass.h" 36 37 MyClass::MyClass() 38 { 39 RegisterObject(MyClass); 40 } 41 }}} 42 43 {{{ 44 #!cpp 45 SomeOtherFile.cc: 46 47 #include "CoreIncludes.h" 48 #include "MyClass.h" 49 50 Identifier* myidentifier = Class(MyClass); 51 std::cout << myidentifier->getName() << std::endl; 52 53 /* 54 returns: 55 MyClass 56 */ 57 }}}