H:/gfcppsancout/product/include/gfcpp/gf_base.hpp

Go to the documentation of this file.
00001 #ifndef _GEMFIRE_GF_BASE_HPP_
00002 #define _GEMFIRE_GF_BASE_HPP_
00003 /*=========================================================================
00004  * (c) Copyright 2002-2007, GemStone Systems, Inc. All Rights Reserved.
00005  * 1260 NW Waterhouse Ave., Suite 200,  Beaverton, OR 97006
00006  *
00007  * The specification of function behaviors is found in the gfc*.cpp files.
00008  *
00009  *========================================================================
00010  */
00011 
00012 
00013 #if defined(_WIN32)
00014 
00015 #define LIBEXP __declspec(dllexport)
00016 
00017 #define LIBIMP __declspec(dllimport)
00018 
00019 #define LIBCALL __stdcall
00020 
00021 #define LIBEXPORT(type) LIBEXP type LIBCALL
00022 #else
00023 
00024 #define LIBEXP
00025 
00026 #define LIBIMP extern
00027 
00028 #define LIBCALL 
00029 
00030 #define LIBEXPORT(type) type
00031 #endif
00032 
00034 #ifdef BUILD_GEMFIRE
00035 #define GFCEXTERN(type) LIBEXP type LIBCALL
00036 #else
00037 #define GFCEXTERN(type) LIBIMP type LIBCALL
00038 #endif /* BUILD_GEMFIRE    */
00039 
00041 #if defined(_WIN32)
00042   #ifdef BUILD_CPPCACHE
00043     #define CPPCACHE_EXPORT LIBEXP
00044   #else
00045     #define CPPCACHE_EXPORT LIBIMP
00046   #endif
00047 #else
00048   #define CPPCACHE_EXPORT
00049 #endif /* BUILD_CPPCACHE */
00050 
00052 #if defined(_WIN32)
00053   #ifdef BUILD_CPPCACHE
00054     #define GF_TEMPLATE_EXPORT __declspec(dllexport)
00055   #else
00056     #define GF_TEMPLATE_EXPORT __declspec(dllimport)
00057   #endif
00058 #else
00059   #define GF_TEMPLATE_EXPORT
00060 #endif
00061 
00062 #if defined(_WIN32)
00063 /* 32 bit Windows only, for now */
00064 typedef signed char      int8; 
00065 typedef unsigned char    uint8; 
00066 typedef signed short     int16; 
00067 typedef unsigned short   uint16; 
00068 typedef signed int       int32; 
00069 typedef unsigned int     uint32; 
00070 typedef signed __int64   int64; 
00071 typedef unsigned __int64 uint64; 
00073 typedef int32            intptr_t; 
00074 typedef uint32           uintptr_t; 
00076 /* Windows does not have stdint.h */
00077 typedef int8             int8_t;
00078 typedef uint8            uint8_t;
00079 typedef int16            int16_t;
00080 typedef uint16           uint16_t;
00081 typedef int32            int32_t;
00082 typedef uint32           uint32_t;
00083 typedef int64            int64_t;
00084 typedef uint64           uint64_t;
00085 /* end stdint.h */
00086 
00087 /* Windows does not have inttypes.h */
00088 /* 32 bit Windows only, for now */
00089 #if !defined PRId8
00090 # define PRId8 "d"
00091 #endif
00092 #if !defined PRIi8
00093 # define PRIi8 "i"
00094 #endif
00095 #if !defined PRIo8
00096 # define PRIo8 "o"
00097 #endif
00098 #if !defined PRIu8
00099 # define PRIu8 "u"
00100 #endif
00101 #if !defined PRIx8
00102 # define PRIx8 "x"
00103 #endif
00104 #if !defined PRIX8
00105 # define PRIX8 "X"
00106 #endif
00107 #if !defined PRId16
00108 # define PRId16 "d"
00109 #endif
00110 #if !defined PRIi16
00111 # define PRIi16 "i"
00112 #endif
00113 #if !defined PRIo16
00114 # define PRIo16 "o"
00115 #endif
00116 #if !defined PRIu16
00117 # define PRIu16 "u"
00118 #endif
00119 #if !defined PRIx16
00120 # define PRIx16 "x"
00121 #endif
00122 #if !defined PRIX16
00123 # define PRIX16 "X"
00124 #endif
00125 #if !defined PRId32
00126 # define PRId32 "d"
00127 #endif
00128 #if !defined PRIi32
00129 # define PRIi32 "i"
00130 #endif
00131 #if !defined PRIo32
00132 # define PRIo32 "o"
00133 #endif
00134 #if !defined PRIu32
00135 # define PRIu32 "u"
00136 #endif
00137 #if !defined PRIx32
00138 # define PRIx32 "x"
00139 #endif
00140 #if !defined PRIX32
00141 # define PRIX32 "X"
00142 #endif
00143 #if !defined PRId64
00144 # define PRId64 "lld"
00145 #endif
00146 #if !defined PRIi64
00147 # define PRIi64 "lli"
00148 #endif
00149 #if !defined PRIo64
00150 # define PRIo64 "llo"
00151 #endif
00152 #if !defined PRIu64
00153 # define PRIu64 "llu"
00154 #endif
00155 #if !defined PRIx64
00156 # define PRIx64 "llx"
00157 #endif
00158 #if !defined PRIX64
00159 # define PRIX64 "llX"
00160 #endif
00161 /* end inttypes.h */
00162 
00163 #ifndef _INC_WCHAR
00164 #include <wchar.h>
00165 #endif
00166 
00167 #else
00168 /* Unix, including both Sparc Solaris and Linux */
00169 #define __STDC_FORMAT_MACROS
00170 #include <inttypes.h>
00171 typedef char             int8; 
00172 typedef unsigned char    uint8; 
00173 typedef short            int16; 
00174 typedef unsigned short   uint16; 
00175 typedef int32_t          int32; 
00176 typedef uint32_t         uint32; 
00177 typedef int64_t          int64; 
00178 typedef uint64_t         uint64; 
00180 #ifndef _WCHAR_H
00181 #include <wchar.h>
00182 #endif
00183 #endif  /* _WIN32*/
00184 
00185 
00186 namespace gemfire {
00187   typedef bool Bool;      
00188   typedef uint8 UInt8;  
00189   typedef int8 Int8;    
00190   typedef uint16 UInt16;  
00191   typedef int16 Int16;    
00192   typedef uint32 UInt32;  
00193   typedef int32 Int32;    
00194   typedef uint64 UInt64;  
00195   typedef int64 Int64;    
00196   typedef int64 Duration; 
00197 }
00198 
00223 typedef uint32  Oid; 
00228 enum {
00229   GF_S_NOTCON = 0,     
00230   GF_S_CONN = 1,       
00231   GF_S_DISCON = 2,     
00232   GF_S_SHUTDN = 3      
00233 };
00234 
00236 #define GF_FALSE 0
00237 
00238 #define GF_TRUE  1
00239 
00241 #define GF_UNPROTECT 0
00242 
00243 #define GF_PROTECT 1
00244 
00249 typedef enum {
00250   GF_NOERR = 0,    
00251   GF_DEADLK = 1,   
00252   GF_EACCES = 2,   
00253   GF_ECONFL = 3,   
00254   GF_EINVAL = 4,   
00255   GF_ENOENT = 5,   
00256   GF_ENOMEM = 6,   
00257   GF_ERANGE = 7,   
00258   GF_ETYPE =  8,   
00259   GF_NOTOBJ = 9,   
00260   GF_NOTCON = 10,  
00261   GF_NOTOWN = 11,  
00262   GF_NOTSUP = 12,  
00263   GF_SCPGBL = 13,  
00264   GF_SCPEXC = 14,  
00265   GF_TIMOUT = 15,  
00266   GF_OVRFLW = 16,  
00267   GF_IOERR =  17,  
00268   GF_EINTR =  18,  
00269   GF_MSG = 19,     
00271   GF_CACHE_REGION_NOT_FOUND = 101, 
00272   GF_CACHE_REGION_INVALID =   102, 
00273   GF_CACHE_REGION_KEYS_NOT_STRINGS = 103,
00274   GF_CACHE_REGION_ENTRY_NOT_BYTES = 104, 
00275   GF_CACHE_REGION_NOT_GLOBAL = 105,      
00276   GF_CACHE_PROXY = 106,                  
00277   GF_CACHE_ILLEGAL_ARGUMENT_EXCEPTION = 107, 
00278   GF_CACHE_ILLEGAL_STATE_EXCEPTION = 108, 
00279   GF_CACHE_TIMEOUT_EXCEPTION = 109, 
00280   GF_CACHE_WRITER_EXCEPTION = 110, 
00281   GF_CACHE_REGION_EXISTS_EXCEPTION = 111, 
00282   GF_CACHE_CLOSED_EXCEPTION = 112, 
00283   GF_CACHE_LEASE_EXPIRED_EXCEPTION = 113, 
00284   GF_CACHE_LOADER_EXCEPTION = 114, 
00285   GF_CACHE_REGION_DESTROYED_EXCEPTION = 115, 
00286   GF_CACHE_ENTRY_DESTROYED_EXCEPTION = 116, 
00287   GF_CACHE_STATISTICS_DISABLED_EXCEPTION = 117, 
00288   GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION = 118, 
00289   GF_CACHE_ENTRY_NOT_FOUND = 119, 
00290   GF_CACHE_ENTRY_EXISTS = 120, 
00291   GF_CACHEWRITER_ERROR=121,  
00292   GF_ENTRYEXISTS_EXCEPTION=122,  
00293   GF_CANNOT_PROCESS_GII_REQUEST=123,  
00294   GF_CACHESERVER_EXCEPTION=124, 
00295   GF_CACHE_REDUNDANCY_FAILURE = 125, 
00296   GF_AUTHENTICATION_FAILED_EXCEPTION = 126, 
00297   GF_NOT_AUTHORIZED_EXCEPTION = 127, 
00298   GF_AUTHENTICATION_REQUIRED_EXCEPTION = 128,
00299   GF_DUPLICATE_DURABLE_CLIENT = 129, 
00300   GF_EUNDEF = 999  
00301 } GfErrType;
00302 
00303 
00305 #define MAX_GII_MESSAGE_SIZE 2 * 1024 * 1024 
00306 
00308 #define GF_MAX_ERR_STR_LEN  256
00309 
00314 typedef struct {
00315     GfErrType errorno; 
00316     char errorString[GF_MAX_ERR_STR_LEN]; 
00317     int32 numArgs; 
00318     Oid args[4]; 
00319 } GfErrorInfo;
00320 
00326 typedef GfErrType (*genericFunc)(void *args);
00327 
00332 typedef enum {
00333   GF_REGION_ERROR_BUF_SIZE = 256   
00334 } GfRegionErrorBufSize;
00335 
00336 
00340 typedef enum{
00341   NO_EVENT, 
00342   AFTER_CREATE,  
00343   AFTER_DESTROY,   
00344   AFTER_INVALIDATE, 
00345   AFTER_REGION_DESTROY,   
00346   AFTER_REGION_INVALIDATE, 
00347   AFTER_UPDATE, 
00348   CLOSE 
00349 } GfCacheEventCodes;
00350 
00362 typedef GfErrType (*GfEventHandlerFunction)(
00363   GfCacheEventCodes  eventCode, 
00364   int8     boolValues, 
00365   Oid      region, 
00366   Oid      callbackArg, 
00367   Oid      key, 
00368   Oid      newValue,  
00369   Oid      oldValue, 
00370   int32    keyLen, 
00371   wchar_t  *keyBuf, 
00372   int32    newValueSize, 
00373   int8     *newValueBuf, 
00374   int32    oldValueSize, 
00375   int8     *oldValueBuf 
00376 );
00377 
00381 #define GF_CACHE_EVENT
00382 
00383 #define GF_CACHE_EVENT_LOCAL_LOAD     0x01
00384 
00385 #define GF_CACHE_EVENT_NET_LOAD       0x02
00386 
00387 #define GF_CACHE_EVENT_NETSEARCH      0x04
00388 
00389 #define GF_CACHE_EVENT_DISTRIBUTED    0x08
00390 
00391 #define GF_CACHE_EVENT_EXPIRATION     0x10
00392 
00393 #define GF_CACHE_EVENT_ORIGIN_REMOTE  0x20
00394 
00399 #define GF_CACHE_EVENT_MASKS
00400 
00401 #define GF_CACHE_EVENT_MASK_AFTER_CREATE            0x01
00402 
00403 #define GF_CACHE_EVENT_MASK_AFTER_DESTROY           0x02
00404 
00405 #define GF_CACHE_EVENT_MASK_AFTER_INVALIDATE        0x04
00406 
00407 #define GF_CACHE_EVENT_MASK_AFTER_REGION_DESTROY    0x08
00408 
00409 #define GF_CACHE_EVENT_MASK_AFTER_REGION_INVALIDATE 0x10
00410 
00411 #define GF_CACHE_EVENT_MASK_AFTER_UPDATE            0x20
00412 
00413 #define GF_CACHE_EVENT_MASK_CLOSE                   0x40
00414 
00415 #define GF_CACHE_EVENT_MASK_ALL                     0x7F
00416 
00417 
00418 #include <new>
00419 
00421 #define GF_SAFE_DELETE(x) \
00422 { \
00423   delete x; \
00424   x = NULL; \
00425 }
00426 
00428 #define GF_SAFE_DELETE_ARRAY(x) \
00429 { \
00430   delete [ ] x; \
00431   x = NULL; \
00432 }
00433 
00435 #define GF_NEW(v, stmt) \
00436 { \
00437   v = new (std::nothrow) stmt; \
00438   if ( (v) == NULL ) { \
00439     throw gemfire::OutOfMemoryException( \
00440         "Out of Memory while allocating "#v ); \
00441   } \
00442 }
00443 
00444 #endif

GemFire C++ Cache API Documentation