Logo Search packages:      
Sourcecode: icu version File versions

typedef void* UClassID

UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ compilers. Each class hierarchy which needs to implement polymorphic clone() or operator==() defines two methods, described in detail below. UClassID values can be compared using operator==(). Nothing else should be done with them.

getDynamicClassID() is declared in the base class of the hierarchy as a pure virtual. Each concrete subclass implements it in the same way:
      class Base {
          virtual UClassID getDynamicClassID() const = 0;

      class Derived {
          virtual UClassID getDynamicClassID() const
            { return Derived::getStaticClassID(); }

Each concrete class implements getStaticClassID() as well, which allows clients to test for a specific type.

      class Derived {
          static UClassID getStaticClassID();
          static char fgClassID;

      // In Derived.cpp:
      UClassID Derived::getStaticClassID()
        { return (UClassID)&Derived::fgClassID; }
      char Derived::fgClassID = 0; // Value is irrelevant

Definition at line 254 of file utypes.h.

Generated by  Doxygen 1.6.0   Back to index