/export/leeloo1/users/build/gfcppsancout64/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(_MSC_VER)
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; /**< a pointer to a 32 bit integer */
00074 //typedef uint32           uintptr_t; /**< a pointer to an unsigned 32 bit integer */
00075 
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 int8_t           int8; 
00172 typedef uint8_t          uint8; 
00173 typedef int16_t          int16; 
00174 typedef uint16_t         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 
00211 #define DEFAULT_QUERY_RESPONSE_TIMEOUT 15
00212 
00217 typedef enum {
00218   GF_NOERR = 0,    
00219   GF_DEADLK = 1,   
00220   GF_EACCES = 2,   
00221   GF_ECONFL = 3,   
00222   GF_EINVAL = 4,   
00223   GF_ENOENT = 5,   
00224   GF_ENOMEM = 6,   
00225   GF_ERANGE = 7,   
00226   GF_ETYPE =  8,   
00227   GF_NOTOBJ = 9,   
00228   GF_NOTCON = 10,  
00229   GF_NOTOWN = 11,  
00230   GF_NOTSUP = 12,  
00231   GF_SCPGBL = 13,  
00232   GF_SCPEXC = 14,  
00233   GF_TIMOUT = 15,  
00234   GF_OVRFLW = 16,  
00235   GF_IOERR =  17,  
00236   GF_EINTR =  18,  
00237   GF_MSG = 19,     
00238   GF_DISKFULL = 20,
00239   GF_NOSERVER_FOUND = 21, 
00240   GF_SERVER_FAILED = 22,
00241 
00242   GF_CACHE_REGION_NOT_FOUND = 101, 
00243   GF_CACHE_REGION_INVALID =   102, 
00244   GF_CACHE_REGION_KEYS_NOT_STRINGS = 103,
00245   GF_CACHE_REGION_ENTRY_NOT_BYTES = 104, 
00246   GF_CACHE_REGION_NOT_GLOBAL = 105,      
00247   GF_CACHE_PROXY = 106,                  
00248   GF_CACHE_ILLEGAL_ARGUMENT_EXCEPTION = 107, 
00249   GF_CACHE_ILLEGAL_STATE_EXCEPTION = 108, 
00250   GF_CACHE_TIMEOUT_EXCEPTION = 109, 
00251   GF_CACHE_WRITER_EXCEPTION = 110, 
00252   GF_CACHE_REGION_EXISTS_EXCEPTION = 111, 
00253   GF_CACHE_CLOSED_EXCEPTION = 112, 
00254   GF_CACHE_LEASE_EXPIRED_EXCEPTION = 113, 
00255   GF_CACHE_LOADER_EXCEPTION = 114, 
00256   GF_CACHE_REGION_DESTROYED_EXCEPTION = 115, 
00257   GF_CACHE_ENTRY_DESTROYED_EXCEPTION = 116, 
00258   GF_CACHE_STATISTICS_DISABLED_EXCEPTION = 117, 
00259   GF_CACHE_CONCURRENT_MODIFICATION_EXCEPTION = 118, 
00260   GF_CACHE_ENTRY_NOT_FOUND = 119, 
00261   GF_CACHE_ENTRY_EXISTS = 120, 
00262   GF_CACHEWRITER_ERROR=121,  
00263   GF_CANNOT_PROCESS_GII_REQUEST=123,  
00264   GF_CACHESERVER_EXCEPTION=124, 
00265   //GF_CACHE_REDUNDANCY_FAILURE = 125, /**< redundancy level not satisfied */
00266   GF_AUTHENTICATION_FAILED_EXCEPTION = 126, 
00267   GF_NOT_AUTHORIZED_EXCEPTION = 127, 
00268   GF_AUTHENTICATION_REQUIRED_EXCEPTION = 128,
00269   GF_DUPLICATE_DURABLE_CLIENT = 129, 
00270   GF_REMOTE_QUERY_EXCEPTION = 130, 
00271   GF_CACHE_LISTENER_EXCEPTION = 131, 
00272   GF_ALL_CONNECTIONS_IN_USE_EXCEPTION = 132, 
00277   GF_CACHE_ENTRY_UPDATED = 133,
00278   GF_CACHE_LOCATOR_EXCEPTION = 134, 
00279   GF_INVALID_DELTA = 135,
00280   GF_FUNCTION_EXCEPTION = 136,
00281   GF_ROLLBACK_EXCEPTION = 137,
00282   GF_COMMIT_CONFLICT_EXCEPTION = 138,
00283   GF_TRANSACTION_DATA_NODE_HAS_DEPARTED_EXCEPTION = 139,
00284   GF_TRANSACTION_DATA_REBALANCED_EXCEPTION = 140,
00285   GF_EUNDEF = 999  
00286 } GfErrType;
00287 
00288 
00289 #include <new>
00290 
00291 #ifdef _WIN32
00292 
00293 typedef void * (* pNew) (size_t);
00294 typedef void (* pDelete) (void *);
00295 
00296 namespace gemfire {
00297   extern void setDefaultNewAndDelete();
00298 }
00299 
00300 void * operator new (size_t size);
00301 void operator delete (void * p);
00302 void * operator new [] (size_t size);
00303 void operator delete [] (void * p);
00304 
00305 #endif // _WIN32
00306 
00308 #define GF_NEW(v, stmt) \
00309 { \
00310   try { \
00311     v = new stmt; \
00312   } \
00313   catch (const std::bad_alloc&) { \
00314     throw gemfire::OutOfMemoryException( \
00315         "Out of Memory while executing \""#v" = new "#stmt";\""); \
00316   } \
00317 }
00318 
00320 #define GF_SAFE_DELETE(x) \
00321 { \
00322   delete x; \
00323   x = NULL; \
00324 }
00325 
00327 #define GF_SAFE_DELETE_ARRAY(x) \
00328 { \
00329   delete [ ] x; \
00330   x = NULL; \
00331 }
00332 
00333 #endif

GemFire C++ Cache API Documentation