= !SubclassIdentifier = [[TracNav(TracNav/TOC_Development)]] == Description == !SubclassIdentifier acts like a pointer to an [wiki:Identifier] with the difference that you can only assign Identifiers of classes inheriting from a given baseclass. !SubclassIdentifier is a [wiki:template]. The template-argument defines the needed base-class of an assigned Identifier. You can only assign 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. == Usage == === Assignment === You can assign an Identifier either through the constructor or by using the assignment operator=: {{{ // SubClass isA BaseClass: SubclassIdentifier identifier = Class(SubClass); }}} === Function calls === the operator-> is overloaded an returns the assigned Identifier. That way you can just call functions of the assigned Identifier by using ->function(): {{{ SubclassIdentifier identifier = Class(SubClass); identifier->getName(); // returns "SubClass" }}} === fabricate() === There are two possibilities to create an object out of a !SubclassIdentifier. Either you just use the fabricate() function of the assigned Identifier through the overloaded operator->. Remember: This function returns a BaseObject* pointer: {{{ // creates a SubClass, returns a BaseObject* pointer identifier->fabricate(); }}} Or you use the function of !SubclassIdentifier, this time by using operator., which returns a BaseClass* pointer (BaseClass is the baseclass specified by the template argument): {{{ // creates a SubClass, returns a BaseClass* pointer identifier.fabricate(); }}} == Examples == The following examples use the class-tree below. {{{ #!cpp SubclassIdentifier myidentifier = Class(A1); // This works SubclassIdentifier myidentifier = Class(A1B1); // This works SubclassIdentifier myidentifier = Class(A1B1C1); // This works SubclassIdentifier myidentifier = Class(BaseObject); // This doesn't work SubclassIdentifier myidentifier = Class(A3); // This doesn't work SubclassIdentifier myidentifier = Class(A3); // This works SubclassIdentifier myidentifier = Class(A2B2C1); // This works }}} {{{ SubclassIdentifier myidentifier = Class(A1B1); myidentifier->isExactlyA(Class(A1)); // Returns false myidentifier->isExactlyA(Class(A1B1)); // Returns true (*myidentifier)->getName(); // Returns "A1B1" myidentifier->getName(); // Returns "A1B1" A1* newobject = myidentifier.fabricate(); // Returns a new instance of A1B1, casted to A1 }}} [[Image(Core:testclass_interface_tree.gif)]]