uobject.h File Reference

C++ API: Common ICU base class UObject. More...

#include "unicode/utypes.h"

Go to the source code of this file.

Data Structures

class  icu::UMemory
 UMemory is the common ICU base class. More...
class  icu::UObject
 UObject is the common ICU "boilerplate" class. More...

Namespaces

namespace  icu
 

File coll.h.


Defines

#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass)
 This is a simple macro to add ICU RTTI to an ICU object implementation.
#define UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass)
 This macro adds ICU RTTI to an ICU abstract class implementation.
#define UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(myClass)   UClassID myClass::getDynamicClassID() const { return NULL; }
 This is a simple macro to express that a class and its subclasses do not offer ICU's "poor man's RTTI".

Typedefs

typedef void * UClassID
 UClassID is used to identify classes without using the compiler's RTTI.

Detailed Description

C++ API: Common ICU base class UObject.

Definition in file uobject.h.


Define Documentation

#define UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION ( myClass   ) 
Value:
UClassID U_EXPORT2 myClass::getStaticClassID() { \
        static char classID = 0; \
        return (UClassID)&classID; \
    }

This macro adds ICU RTTI to an ICU abstract class implementation.

This macro should be invoked in *.cpp files. The corresponding header should declare getStaticClassID.

Parameters:
myClass The name of the class that needs RTTI defined.
Internal:
Do not use. This API is for internal use only.

Definition at line 329 of file uobject.h.

#define UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION ( myClass   )     UClassID myClass::getDynamicClassID() const { return NULL; }

This is a simple macro to express that a class and its subclasses do not offer ICU's "poor man's RTTI".

Beginning with ICU 4.6, ICU requires C++ compiler RTTI. This does not go into the header. This should only be used in *.cpp files. Use this with a private getDynamicClassID() in an immediate subclass of UObject.

Parameters:
myClass The name of the class that needs RTTI defined.
Internal:
Do not use. This API is for internal use only.

Definition at line 345 of file uobject.h.

#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION ( myClass   ) 
Value:
UClassID U_EXPORT2 myClass::getStaticClassID() { \
        static char classID = 0; \
        return (UClassID)&classID; \
    } \
    UClassID myClass::getDynamicClassID() const \
    { return myClass::getStaticClassID(); }

This is a simple macro to add ICU RTTI to an ICU object implementation.

This does not go into the header. This should only be used in *.cpp files.

Parameters:
myClass The name of the class that needs RTTI defined.
Internal:
Do not use. This API is for internal use only.

Definition at line 312 of file uobject.h.


Typedef Documentation

typedef void* UClassID

UClassID is used to identify classes without using the compiler's RTTI.

This was used before C++ compilers consistently supported RTTI. ICU 4.6 requires compiler RTTI to be turned on.

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
Stable:
ICU 2.0

Definition at line 96 of file uobject.h.


Generated on 25 Nov 2014 for ICU 50.1.2 by  doxygen 1.6.1