00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __UOBJECT_H__
00018 #define __UOBJECT_H__
00019
00020 #include "unicode/utypes.h"
00021
00041 #ifndef U_NO_THROW
00042 #define U_NO_THROW throw()
00043 #endif
00044
00047
00048
00049
00050
00091 typedef void* UClassID;
00092
00093 U_NAMESPACE_BEGIN
00094
00110 class U_COMMON_API UMemory {
00111 public:
00112
00113
00114 #ifdef SHAPER_MEMORY_DEBUG
00115 static void * NewArray(int size, int count);
00116 static void * GrowArray(void * array, int newSize );
00117 static void FreeArray(void * array );
00118 #endif
00119
00120 #if U_OVERRIDE_CXX_ALLOCATION
00121
00129 static void * U_EXPORT2 operator new(size_t size) U_NO_THROW;
00130
00136 static void * U_EXPORT2 operator new[](size_t size) U_NO_THROW;
00137
00146 static void U_EXPORT2 operator delete(void *p) U_NO_THROW;
00147
00153 static void U_EXPORT2 operator delete[](void *p) U_NO_THROW;
00154
00155 #if U_HAVE_PLACEMENT_NEW
00156
00161 static inline void * U_EXPORT2 operator new(size_t, void *ptr) U_NO_THROW { return ptr; }
00162
00168 static inline void U_EXPORT2 operator delete(void *, void *) U_NO_THROW {}
00169 #endif
00170 #if U_HAVE_DEBUG_LOCATION_NEW
00171
00178 static void * U_EXPORT2 operator new(size_t size, const char* file, int line) U_NO_THROW;
00186 static void U_EXPORT2 operator delete(void* p, const char* file, int line) U_NO_THROW;
00187 #endif
00188 #endif
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 };
00201
00221 class U_COMMON_API UObject : public UMemory {
00222 public:
00228 virtual ~UObject();
00229
00239 virtual UClassID getDynamicClassID() const;
00240
00241 protected:
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 #if 0
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 virtual inline UBool operator==(const UObject &other) const { return this==&other; }
00264 inline UBool operator!=(const UObject &other) const { return !operator==(other); }
00265
00266
00267
00268
00269
00270
00271 #endif
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 };
00284
00285 #ifndef U_HIDE_INTERNAL_API
00286
00293 #define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass) \
00294 UClassID U_EXPORT2 myClass::getStaticClassID() { \
00295 static char classID = 0; \
00296 return (UClassID)&classID; \
00297 } \
00298 UClassID myClass::getDynamicClassID() const \
00299 { return myClass::getStaticClassID(); }
00300
00301
00310 #define UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass) \
00311 UClassID U_EXPORT2 myClass::getStaticClassID() { \
00312 static char classID = 0; \
00313 return (UClassID)&classID; \
00314 }
00315
00316 #endif
00317
00318 U_NAMESPACE_END
00319
00320 #endif