ICU-1232 add class ID support (required)

X-SVN-Rev: 6703
This commit is contained in:
Alan Liu 2001-11-09 01:22:59 +00:00
parent 51f23530aa
commit 14b757eeb9
2 changed files with 71 additions and 0 deletions

View File

@ -141,6 +141,51 @@ public:
*/
virtual UBool matchesIndexValue(uint8_t v) const = 0;
/**
* Return the class ID for this class. This is useful only for
* comparing to a return value from getDynamicClassID(). For example:
* <pre>
* . Base* polymorphic_pointer = createPolymorphicObject();
* . if (polymorphic_pointer->getDynamicClassID() ==
* . Derived::getStaticClassID()) ...
* </pre>
* @return The class ID for all objects of this class.
* @stable
*/
static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
/**
* Returns a unique class ID <b>polymorphically</b>. This method
* is to implement a simple version of RTTI, since not all C++
* compilers support genuine RTTI. Polymorphic operator==() and
* clone() methods call this method.
*
* <p>Concrete subclasses of UnicodeMatcher that wish clients to
* be able to identify them should implement getDynamicClassID()
* and also a static method and data member:
*
* <pre>
* static UClassID getStaticClassID() { return (UClassID)&fgClassID; }
* static char fgClassID;
* </pre>
*
* Subclasses that do not implement this method will have a
* dynamic class ID of UnicodeMatcher::getStatisClassID().
*
* @return The class ID for this object. All objects of a given
* class have the same class ID. Objects of other classes have
* different class IDs.
*/
virtual UClassID getDynamicClassID(void) const { return getStaticClassID(); };
private:
/**
* Class identifier for subclasses of UnicodeMatcher that do not
* define their class (anonymous subclasses).
*/
static const char fgClassID;
protected:
UnicodeMatcher();

View File

@ -623,6 +623,32 @@ public:
*/
virtual void compact();
/**
* Return the class ID for this class. This is useful only for
* comparing to a return value from getDynamicClassID(). For example:
* <pre>
* . Base* polymorphic_pointer = createPolymorphicObject();
* . if (polymorphic_pointer->getDynamicClassID() ==
* . Derived::getStaticClassID()) ...
* </pre>
* @return The class ID for all objects of this class.
* @stable
*/
static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
/**
* Implement UnicodeMatcher API.
*
* @return The class ID for this object. All objects of a given
* class have the same class ID. Objects of other classes have
* different class IDs.
*/
virtual UClassID getDynamicClassID(void) const { return getStaticClassID(); };
private:
static const char fgClassID;
private:
//----------------------------------------------------------------