Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/SubclassIdentifier


Ignore:
Timestamp:
Feb 25, 2008, 12:14:47 AM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/SubclassIdentifier

    v1 v1  
     1= !SubclassIdentifier =
     2
     3== Description ==
     4
     5The [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
     11The following examples use the class-tree below.
     12
     13{{{
     14#!cpp
     15SubclassIdentifier<A1> myidentifier = Class(A1);             // This works
     16SubclassIdentifier<A1> myidentifier = Class(A1B1);           // This works
     17SubclassIdentifier<A1> myidentifier = Class(A1B1C1);         // This works
     18SubclassIdentifier<A1> myidentifier = Class(BaseObject);     // This doesn't work
     19SubclassIdentifier<A1> myidentifier = Class(A3);             // This doesn't work
     20
     21
     22SubclassIdentifier<Interface1> myidentifier = Class(A3);     // This works
     23SubclassIdentifier<Interface1> myidentifier = Class(A2B2C1); // This works
     24
     25
     26SubclassIdentifier<A1> myidentifier = Class(A1B1);
     27myidentifier.isExactlyA(Class(A1));       // Returns false
     28myidentifier.isExactlyA(Class(A1B1));     // Returns true
     29(*myidentifier)->getName();               // Returns "A1B1"
     30myidentifier->getName();                  // Returns "A1B1" (And yes, the "->" is correct. It's overloaded.)
     31
     32A1* newobject = myidentifier.fabricate(); // Returns a new instance of A1B1, downcasted to A1
     33}}}
     34
     35[[Image(Core:testclass_interface_tree.gif)]]