00001 #ifndef _GEMFIRE_GF_BASE_HPP_
00002 #define _GEMFIRE_GF_BASE_HPP_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #if defined(_WIN32)
00016
00017 #define LIBEXP __declspec(dllexport)
00018
00019 #define LIBIMP __declspec(dllimport)
00020
00021 #define LIBCALL __stdcall
00022
00023 #define LIBEXPORT(type) LIBEXP type LIBCALL
00024 #else
00025
00026 #define LIBEXP
00027
00028 #define LIBIMP extern
00029
00030 #define LIBCALL
00031
00032 #define LIBEXPORT(type) type
00033 #endif
00034
00036 #ifdef BUILD_GEMFIRE
00037 #define GFCEXTERN(type) LIBEXP type LIBCALL
00038 #else
00039 #define GFCEXTERN(type) LIBIMP type LIBCALL
00040 #endif
00041
00043 #if defined(_WIN32)
00044 #ifdef BUILD_CPPCACHE
00045 #define CPPCACHE_EXPORT LIBEXP
00046 #else
00047 #define CPPCACHE_EXPORT LIBIMP
00048 #endif
00049 #else
00050 #define CPPCACHE_EXPORT
00051 #endif
00052
00054 #if defined(_WIN32)
00055 #ifdef BUILD_CPPCACHE
00056 #define GF_TEMPLATE_EXPORT __declspec(dllexport)
00057 #else
00058 #define GF_TEMPLATE_EXPORT __declspec(dllimport)
00059 #endif
00060 #else
00061 #define GF_TEMPLATE_EXPORT
00062 #endif
00063
00064 #if defined(_MSC_VER)
00065
00066 typedef signed char int8;
00067 typedef unsigned char uint8;
00068 typedef signed short int16;
00069 typedef unsigned short uint16;
00070 typedef signed int int32;
00071 typedef unsigned int uint32;
00072 typedef signed __int64 int64;
00073 typedef unsigned __int64 uint64;
00075
00076
00077
00078
00079 typedef int8 int8_t;
00080 typedef uint8 uint8_t;
00081 typedef int16 int16_t;
00082 typedef uint16 uint16_t;
00083 typedef int32 int32_t;
00084 typedef uint32 uint32_t;
00085 typedef int64 int64_t;
00086 typedef uint64 uint64_t;
00087
00088
00089
00090
00091 #if !defined PRId8
00092 # define PRId8 "d"
00093 #endif
00094 #if !defined PRIi8
00095 # define PRIi8 "i"
00096 #endif
00097 #if !defined PRIo8
00098 # define PRIo8 "o"
00099 #endif
00100 #if !defined PRIu8
00101 # define PRIu8 "u"
00102 #endif
00103 #if !defined PRIx8
00104 # define PRIx8 "x"
00105 #endif
00106 #if !defined PRIX8
00107 # define PRIX8 "X"
00108 #endif
00109 #if !defined PRId16
00110 # define PRId16 "d"
00111 #endif
00112 #if !defined PRIi16
00113 # define PRIi16 "i"
00114 #endif
00115 #if !defined PRIo16
00116 # define PRIo16 "o"
00117 #endif
00118 #if !defined PRIu16
00119 # define PRIu16 "u"
00120 #endif
00121 #if !defined PRIx16
00122 # define PRIx16 "x"
00123 #endif
00124 #if !defined PRIX16
00125 # define PRIX16 "X"
00126 #endif
00127 #if !defined PRId32
00128 # define PRId32 "d"
00129 #endif
00130 #if !defined PRIi32
00131 # define PRIi32 "i"
00132 #endif
00133 #if !defined PRIo32
00134 # define PRIo32 "o"
00135 #endif
00136 #if !defined PRIu32
00137 # define PRIu32 "u"
00138 #endif
00139 #if !defined PRIx32
00140 # define PRIx32 "x"
00141 #endif
00142 #if !defined PRIX32
00143 # define PRIX32 "X"
00144 #endif
00145 #if !defined PRId64
00146 # define PRId64 "lld"
00147 #endif
00148 #if !defined PRIi64
00149 # define PRIi64 "lli"
00150 #endif
00151 #if !defined PRIo64
00152 # define PRIo64 "llo"
00153 #endif
00154 #if !defined PRIu64
00155 # define PRIu64 "llu"
00156 #endif
00157 #if !defined PRIx64
00158 # define PRIx64 "llx"
00159 #endif
00160 #if !defined PRIX64
00161 # define PRIX64 "llX"
00162 #endif
00163
00164
00165 #ifndef _INC_WCHAR
00166 #include <wchar.h>
00167 #endif
00168
00169 #else
00170
00171 #define __STDC_FORMAT_MACROS
00172 #include <inttypes.h>
00173 typedef int8_t int8;
00174 typedef uint8_t uint8;
00175 typedef int16_t int16;
00176 typedef uint16_t uint16;
00177 typedef int32_t int32;
00178 typedef uint32_t uint32;
00179 typedef int64_t int64;
00180 typedef uint64_t uint64;
00182 #ifndef _WCHAR_H
00183 #include <wchar.h>
00184 #endif
00185 #endif
00186
00187
00213 #define DEFAULT_QUERY_RESPONSE_TIMEOUT 15
00214
00219 typedef enum {
00220 GF_NOERR = 0,
00221 GF_DEADLK = 1,
00222 GF_EACCES = 2,
00223 GF_ECONFL = 3,
00224 GF_EINVAL = 4,
00225 GF_ENOENT = 5,
00226 GF_ENOMEM = 6,
00227 GF_ERANGE = 7,
00228 GF_ETYPE = 8,
00229 GF_NOTOBJ = 9,
00230 GF_NOTCON = 10,
00231 GF_NOTOWN = 11,
00232 GF_NOTSUP = 12,
00233 GF_SCPGBL = 13,
00234 GF_SCPEXC = 14,
00235 GF_TIMOUT = 15,
00236 GF_OVRFLW = 16,
00237 GF_IOERR = 17,
00238 GF_EINTR = 18,
00239 GF_MSG = 19,
00240 GF_DISKFULL = 20,
00241 GF_NOSERVER_FOUND = 21,
00242 GF_SERVER_FAILED = 22,
00243
00244 GF_CLIENT_WAIT_TIMEOUT = 23,
00245 GF_CLIENT_WAIT_TIMEOUT_REFRESH_PRMETADATA = 24,
00246
00247 GF_CACHE_REGION_NOT_FOUND = 101,
00248 GF_CACHE_REGION_INVALID = 102,
00249 GF_CACHE_REGION_KEYS_NOT_STRINGS = 103,
00250 GF_CACHE_REGION_ENTRY_NOT_BYTES = 104,
00251 GF_CACHE_REGION_NOT_GLOBAL = 105,
00252 GF_CACHE_PROXY = 106,
00253 GF_CACHE_ILLEGAL_ARGUMENT_EXCEPTION = 107,
00254 GF_CACHE_ILLEGAL_STATE_EXCEPTION = 108,
00255 GF_CACHE_TIMEOUT_EXCEPTION = 109,
00256 GF_CACHE_WRITER_EXCEPTION = 110,
00257 GF_CACHE_REGION_EXISTS_EXCEPTION = 111,
00258 GF_CACHE_CLOSED_EXCEPTION = 112,
00259 GF_CACHE_LEASE_EXPIRED_EXCEPTION = 113,
00260 GF_CACHE_LOADER_EXCEPTION = 114,
00261 GF_CACHE_REGION_DESTROYED_EXCEPTION = 115,
00262 GF_CACHE_ENTRY_DESTROYED_EXCEPTION = 116,
00263 GF_CACHE_STATISTICS_DISABLED_EXCEPTION = 117,
00264 GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION = 118,
00265 GF_CACHE_ENTRY_NOT_FOUND = 119,
00266 GF_CACHE_ENTRY_EXISTS = 120,
00267 GF_CACHEWRITER_ERROR=121,
00268 GF_CANNOT_PROCESS_GII_REQUEST=123,
00269 GF_CACHESERVER_EXCEPTION=124,
00270
00271 GF_AUTHENTICATION_FAILED_EXCEPTION = 126,
00272 GF_NOT_AUTHORIZED_EXCEPTION = 127,
00273 GF_AUTHENTICATION_REQUIRED_EXCEPTION = 128,
00274 GF_DUPLICATE_DURABLE_CLIENT = 129,
00275 GF_REMOTE_QUERY_EXCEPTION = 130,
00276 GF_CACHE_LISTENER_EXCEPTION = 131,
00277 GF_ALL_CONNECTIONS_IN_USE_EXCEPTION = 132,
00282 GF_CACHE_ENTRY_UPDATED = 133,
00283 GF_CACHE_LOCATOR_EXCEPTION = 134,
00284 GF_INVALID_DELTA = 135,
00285 GF_FUNCTION_EXCEPTION = 136,
00286 GF_ROLLBACK_EXCEPTION = 137,
00287 GF_COMMIT_CONFLICT_EXCEPTION = 138,
00288 GF_TRANSACTION_DATA_NODE_HAS_DEPARTED_EXCEPTION = 139,
00289 GF_TRANSACTION_DATA_REBALANCED_EXCEPTION = 140,
00290 GF_PUTALL_PARTIAL_RESULT_EXCEPTION = 141,
00291 GF_EUNDEF = 999
00292 } GfErrType;
00293
00294
00295 #include <new>
00296
00297 #ifdef _WIN32
00298
00299 typedef void * (* pNew) (size_t);
00300 typedef void (* pDelete) (void *);
00301
00302 namespace gemfire {
00303 extern void setDefaultNewAndDelete();
00304 }
00305
00306 void * operator new (size_t size);
00307 void operator delete (void * p);
00308 void * operator new [] (size_t size);
00309 void operator delete [] (void * p);
00310
00311 #endif // _WIN32
00312
00314 #define GF_NEW(v, stmt) \
00315 { \
00316 try { \
00317 v = new stmt; \
00318 } \
00319 catch (const std::bad_alloc&) { \
00320 throw gemfire::OutOfMemoryException( \
00321 "Out of Memory while executing \""#v" = new "#stmt";\""); \
00322 } \
00323 }
00324
00326 #define GF_SAFE_DELETE(x) \
00327 { \
00328 delete x; \
00329 x = NULL; \
00330 }
00331
00333 #define GF_SAFE_DELETE_ARRAY(x) \
00334 { \
00335 delete [ ] x; \
00336 x = NULL; \
00337 }
00338
00339 #endif