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 {
      public:
          virtual UClassID getDynamicClassID() const = 0;
      }

      class Derived {
      public:
          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 {
      public:
          static UClassID U_EXPORT2 getStaticClassID();
      private:
          static char fgClassID;
      }

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

Definition at line 339 of file utypes.h.


Generated by  Doxygen 1.6.0   Back to index