00001 /* 00002 ****************************************************************************** 00003 * 00004 * Copyright (C) 2002, International Business Machines 00005 * Corporation and others. All Rights Reserved. 00006 * 00007 ****************************************************************************** 00008 * file name: uobject.h 00009 * encoding: US-ASCII 00010 * tab size: 8 (not used) 00011 * indentation:4 00012 * 00013 * created on: 2002jun26 00014 * created by: Markus W. Scherer 00015 */ 00016 00017 #ifndef __UOBJECT_H__ 00018 #define __UOBJECT_H__ 00019 00020 #include "unicode/utypes.h" 00021 00022 U_NAMESPACE_BEGIN 00023 00037 #ifndef U_OVERRIDE_CXX_ALLOCATION 00038 #define U_OVERRIDE_CXX_ALLOCATION 1 00039 #endif 00040 00063 class U_COMMON_API UObject { 00064 public: 00070 virtual inline ~UObject() {} 00071 00072 00073 #if U_OVERRIDE_CXX_ALLOCATION 00074 00082 void *operator new(size_t size); 00083 void *operator new[](size_t size); 00084 00093 void operator delete(void *p); 00094 void operator delete[](void *p); 00095 #endif 00096 00102 virtual inline UClassID getDynamicClassID() const = 0; 00103 00104 protected: 00105 // the following functions are protected to prevent instantiation and 00106 // direct use of UObject itself 00107 00108 // default constructor 00109 // commented out because UObject is abstract (see getDynamicClassID) 00110 // inline UObject() {} 00111 00112 // copy constructor 00113 // commented out because UObject is abstract (see getDynamicClassID) 00114 // inline UObject(const UObject &other) {} 00115 00116 #if U_ICU_VERSION_MAJOR_NUM>2 || (U_ICU_VERSION_MAJOR_NUM==2 && U_ICU_VERSION_MINOR_NUM>2) 00117 // TODO post ICU 2.2 00118 // some or all of the following "boilerplate" functions may be made public 00119 // in a future ICU4C release when all subclasses implement them 00120 00121 // assignment operator 00122 // (not virtual, see "Taligent's Guide to Designing Programs" pp.73..74) 00123 // commented out because the implementation is the same as a compiler's default 00124 // UObject &operator=(const UObject &other) { return *this; } 00125 00126 // comparison operators 00127 virtual inline UBool operator==(const UObject &other) const { return this==&other; } 00128 inline UBool operator!=(const UObject &other) const { return !operator==(other); } 00129 00130 // clone() commented out from the base class: 00131 // some compilers do not support co-variant return types 00132 // (i.e., subclasses would have to return UObject * as well, instead of SubClass *) 00133 // virtual UObject *clone() const; 00134 #endif 00135 }; 00136 00137 U_NAMESPACE_END 00138 00139 #endif