| | 1 | = !SubclassIdentifier = |
| | 2 | |
| | 3 | == Description == |
| | 4 | |
| | 5 | The [wiki:SubclassIdentifier] acts like an [wiki:Identifier]. You can assign a [wiki:ClassIdentifier] and compare it with other [wiki:Identifier Identifiers] by using isA(...), isChildOf(...) and other functions. |
| | 6 | |
| | 7 | [wiki:SubclassIdentifier] is a template. The template-class defines the needed base-class of an assigned Identifier. You can only assign [wiki:Identifier Identifiers] representing a class which is derived from the given base-class (or the base-class itself). If you try to assign an Identifier that's not derived from the base-class, you get an error. |
| | 8 | |
| | 9 | == Examples == |
| | 10 | |
| | 11 | The following examples use the class-tree below. |
| | 12 | |
| | 13 | {{{ |
| | 14 | #!cpp |
| | 15 | SubclassIdentifier<A1> myidentifier = Class(A1); // This works |
| | 16 | SubclassIdentifier<A1> myidentifier = Class(A1B1); // This works |
| | 17 | SubclassIdentifier<A1> myidentifier = Class(A1B1C1); // This works |
| | 18 | SubclassIdentifier<A1> myidentifier = Class(BaseObject); // This doesn't work |
| | 19 | SubclassIdentifier<A1> myidentifier = Class(A3); // This doesn't work |
| | 20 | |
| | 21 | |
| | 22 | SubclassIdentifier<Interface1> myidentifier = Class(A3); // This works |
| | 23 | SubclassIdentifier<Interface1> myidentifier = Class(A2B2C1); // This works |
| | 24 | |
| | 25 | |
| | 26 | SubclassIdentifier<A1> myidentifier = Class(A1B1); |
| | 27 | myidentifier.isExactlyA(Class(A1)); // Returns false |
| | 28 | myidentifier.isExactlyA(Class(A1B1)); // Returns true |
| | 29 | (*myidentifier)->getName(); // Returns "A1B1" |
| | 30 | myidentifier->getName(); // Returns "A1B1" (And yes, the "->" is correct. It's overloaded.) |
| | 31 | |
| | 32 | A1* newobject = myidentifier.fabricate(); // Returns a new instance of A1B1, downcasted to A1 |
| | 33 | }}} |
| | 34 | |
| | 35 | [[Image(Core:testclass_interface_tree.gif)]] |