00001 // ***************************************************************************** 00002 // ***************************************************************************** 00003 // oaException.h 00004 // 00005 // This file contains the definitions for the oaException, oaError, oaOSError 00006 // and other derived error classes. These classes implement various types of 00007 // exception objects that OpenAccess may throw. 00008 // 00009 // oaException 00010 // This is the base class for all the OA exceptions and errors. 00011 // 00012 // oaError 00013 // This is the generic error class that is usually thrown by OA 00014 // implementation. 00015 // 00016 // oaOSError 00017 // 00018 // oaSocketError 00019 // 00020 // oaCompatiblityError 00021 // This new error class is not defined in this header, but it represents 00022 // the errors while data compatibility is limited by the presence of 00023 // future features in the data. 00024 // 00025 // oaMemoryError 00026 // This error class is designed to be used when the process run out of 00027 // memory. It does the allocation and initialzation seperately. 00028 // ***************************************************************************** 00029 // Except as specified in the OpenAccess terms of use of Cadence or Silicon 00030 // Integration Initiative, this material may not be copied, modified, 00031 // re-published, uploaded, executed, or distributed in any way, in any medium, 00032 // in whole or in part, without prior written permission from Cadence. 00033 // 00034 // Copyright 2002-2005 Cadence Design Systems, Inc. 00035 // All Rights Reserved. 00036 // 00037 // $Author: icftcm $ 00038 // $Revision: #1 $ 00039 // $Date: 2010/08/09 $ 00040 // $State: Exp $ 00041 // ***************************************************************************** 00042 // ***************************************************************************** 00043 00044 00045 00046 #if !defined(oaException_P) 00047 #define oaException_P 00048 00049 00050 00051 // ***************************************************************************** 00052 // Nested includes 00053 // ***************************************************************************** 00054 #include "oaString.h" 00055 #include "oaArray.h" 00056 #include <stdarg.h> 00057 00058 00059 00060 // ***************************************************************************** 00061 // Declare and define types in the OpenAccess namespace. 00062 // ***************************************************************************** 00063 BEGIN_OA_NAMESPACE 00064 00065 00066 00067 // ***************************************************************************** 00068 // Debug purpose Macro definitions 00069 // ***************************************************************************** 00070 #ifdef NDEBUG 00071 #define oaValidate(exp, errorID) ((void)0) 00072 #define oaAssert(exp) ((void)0) 00073 #define oaInternalError(str) ((void)0) 00074 #define oaUnexpectedCase(value) ((void)0) 00075 #else 00076 #define oaValidate(exp, errorID) \ 00077 {\ 00078 if (!(exp)) {\ 00079 throw oa::oaError(errorID);\ 00080 }\ 00081 } 00082 #define oaAssert(exp) \ 00083 {\ 00084 if (!(exp)) {\ 00085 throw oa::oaError(oa::oacInternalError, #exp, __FILE__, __LINE__);\ 00086 }\ 00087 } 00088 #define oaInternalError(str) throw oa::oaError(oa::oacInternalError, str, __FILE__, __LINE__) 00089 #define oaUnexpectedCase(value) \ 00090 {\ 00091 oa::oaString str;\ 00092 \ 00093 str.format("Unexpected case %d", (oaUInt4) value);\ 00094 \ 00095 throw oa::oaError(oa::oacInternalError, (const char *) str, __FILE__, __LINE__);\ 00096 } 00097 #endif 00098 00099 00100 00101 // ***************************************************************************** 00102 // oaException 00103 // ***************************************************************************** 00104 class OA_BASE_DLL_API oaException { 00105 public: 00106 oaException(oaUInt4 msgIdIn); 00107 virtual inline ~oaException(); 00108 00109 oaUInt4 getMsgId() const; 00110 const oaString &getMsg() const; 00111 00112 static oaUInt8 getLastOSError(); 00113 00114 protected: 00115 virtual const oaString &getFormatString() const; 00116 00117 void format(va_list &args); 00118 static oaUInt4 getOSErrorStr(oaString &errStr); 00119 00120 oaUInt4 msgId; 00121 oaString msg; 00122 }; 00123 00124 00125 00126 // ***************************************************************************** 00127 // oaError 00128 // ***************************************************************************** 00129 class OA_BASE_DLL_API oaError : public oaException { 00130 public: 00131 oaError(oaUInt4 msgIdIn, 00132 ...); 00133 }; 00134 00135 00136 00137 // ***************************************************************************** 00138 // oaOSError 00139 // ***************************************************************************** 00140 class OA_BASE_DLL_API oaOSError : public oaException { 00141 public: 00142 oaOSError(); 00143 }; 00144 00145 00146 00147 // ***************************************************************************** 00148 // oaSocketError 00149 // ***************************************************************************** 00150 class OA_BASE_DLL_API oaSocketError : public oaException { 00151 public: 00152 oaSocketError(); 00153 }; 00154 00155 00156 00157 // ***************************************************************************** 00158 // oaCompatibilityError 00159 // ***************************************************************************** 00160 class OA_BASE_DLL_API oaCompatibilityError : public oaException { 00161 public: 00162 oaCompatibilityError(oaUInt4 msgIdIn, 00163 const oaString &dbNameIn, 00164 const oaString &dbType, 00165 const oaString &dbDataModelBuildNameIn, 00166 oaUInt4 dbDataModelRevIn, 00167 const oaFeatureArray &features, 00168 oaUInt4 limitType); 00169 00170 const oaString &getAppBuildName() const; 00171 const oaString &getKitBuildName() const; 00172 const oaString &getDataModelBuildName() const; 00173 const oaString &getDatabaseName() const; 00174 00175 oaUInt4 getAppDataModelRev() const; 00176 oaUInt4 getKitDataModelRev() const; 00177 oaUInt4 getDBDataModelRev() const; 00178 00179 const oaFeatureArray &getFeatures() const; 00180 00181 private: 00182 oaFeatureArray features; 00183 oaString dbDataModelBuildName; 00184 oaUInt4 dbDataModelRev; 00185 oaString dbName; 00186 }; 00187 00188 00189 00190 // ***************************************************************************** 00191 // oaMemoryError 00192 // ***************************************************************************** 00193 class OA_BASE_DLL_API oaMemoryError : public oaException { 00194 public: 00195 virtual ~oaMemoryError(); 00196 00197 oaUInt8 getAllocSize() const; 00198 oaUInt8 getSbrk() const; 00199 oaUInt8 getOAVMSize() const; 00200 oaUInt8 getAvailableMem() const; 00201 oaUInt8 getPhysicalMem() const; 00202 oaUInt8 getLimitMem() const; 00203 oaBoolean isUnlimited() const; 00204 00205 private: 00206 oaMemoryError(); 00207 void setValues(oaUInt4 newMsgId, 00208 size_t size); 00209 00210 oaUInt8 allocSize; 00211 oaUInt8 sbrkDiff; 00212 oaUInt8 oaVMSize; 00213 oaUInt8 available; 00214 oaUInt8 physical; 00215 oaUInt8 limit; 00216 void *obsolete; 00217 00218 friend class oaMemoryErrorFactory; 00219 }; 00220 00221 00222 00223 END_OA_NAMESPACE 00224 00225 #endif
Copyright © 2002 - 2010 Cadence Design Systems, Inc.
All Rights Reserved.