Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SQLDBC_IRuntime.h

Go to the documentation of this file.
00001 
00031 #ifndef SQLDBC_IRUNTIME_H
00032 #define SQLDBC_IRUNTIME_H
00033 
00034 // For encoding
00035 #include "Interfaces/SQLDBC/SQLDBC_Types.h"
00036 #include "SAPDBCommon/SAPDB_Types.h"
00037 #include "SAPDBCommon/SAPDB_ReuseLib.h"
00038 #include "SAPDB/SAPDBCommon/ErrorsAndMessages/SAPDBErr_MessageList.hpp"
00039 
00040 #ifndef Msg_List
00041 #  define Msg_List SAPDBErr_MessageList
00042 #endif
00043 
00044 class SAPDBMem_IRawAllocator;
00045 
00046 #ifdef _WIN32 
00047 #define SQLDBC_DLLEXPORT __declspec(dllexport)
00048 #else
00049 #define SQLDBC_DLLEXPORT
00050 #endif
00051   
00095 class SQLDBC_IRuntime
00096 {
00097 public:
00101     typedef void *MutexHandle;
00102 
00106     typedef void *SemaphoreHandle;
00107 
00111     typedef void *CounterHandle;
00112 
00116     struct TaskTraceContext
00117     {
00118         void           *currentEntry;   
00119         // -- further settings, used by the trace stream abstraction.
00120         SAPDB_Bool  hex;               
00121         SAPDB_UInt4 inputlength;       
00122         SQLDBC_StringEncoding encoding;
00123         SAPDB_UInt4 indent;            
00124         SAPDB_UInt4 flags;             
00125         SAPDB_UInt4 traceableLimit;    
00126         SAPDB_UInt4 pos;               
00127     };
00128         
00132     typedef SAPDB_UInt4 TaskID;
00133 
00137     virtual ~SQLDBC_IRuntime() {}
00138 
00144     virtual const char *getIdentifier() const { return ""; }
00145 
00172     virtual SAPDB_Bool checkKeyOption(const char *keyoption,
00173                                       char *servernode,
00174                                       SAPDB_Int4& servernodelength,
00175                                       char *serverdb,
00176                                       SAPDB_Int4& serverdblength,
00177                                       SAPDB_Int4& isolationlevel,
00178                                       SAPDB_Int4& cachelimit,
00179                                       SAPDB_Int4& sqlmode,
00180                                       SAPDB_Int4& timeout,
00181                                       char *username,
00182                                       SAPDB_Int4& usernamelength,
00183                                       SQLDBC_StringEncoding& usernameEncoding,
00184                                       Msg_List& errorMessages)
00185     {
00186         return false;
00187     }
00188                                   
00189 
00190     
00201     virtual SAPDBMem_IRawAllocator& getGlobalAllocator() = 0;
00202 
00203     // Packet and Session Handling
00204 
00242     virtual SAPDB_Bool getSession(const char *connectUrl,
00243                                   const char *connectCommand,
00244                                   const char *password,
00245                                   SAPDB_Int4  passwordLength,
00246                                   const SQLDBC_StringEncoding commandEncoding,
00247                                   SAPDB_Int8&  sessionID,
00248                                   SAPDB_UInt4& packetSize,
00249                                   SAPDB_Int4& packetListSize,
00250                                   void **packetList,  
00251                                   void **sessionInfoReply,
00252                                   Msg_List& errorMessages,
00253                                   SAPDBMem_IRawAllocator* allocator = 0) = 0;
00254 
00263     virtual SAPDB_Bool releaseSession(SAPDB_Int8 sessionID,
00264                                       Msg_List& errorMessages) = 0;
00265     
00276     virtual SAPDB_Bool request(SAPDB_Int8  sessionID,
00277                                void       *requestData,
00278                                SAPDB_UInt4 requestDataLength,
00279                                Msg_List& errorMessages) = 0; 
00280 
00290     virtual SAPDB_Bool receive(SAPDB_Int8 sessionID,
00291                                void **replyData,
00292                                SAPDB_Int4& replyDataLength,
00293                                Msg_List& errorMessages) = 0;
00294 
00302     virtual SAPDB_Bool cancelCurrentCommand(SAPDB_Int8 sessionID,
00303                                             Msg_List& errorMessages) = 0;
00304 
00305     // -- synchronization primitives
00315     virtual SAPDB_Bool createMutex(MutexHandle& mutexHandle, 
00316                                    SAPDBMem_IRawAllocator& allocator,
00317                                    Msg_List& errorMessages)  = 0;
00318 
00325     virtual SAPDB_Bool lockMutex(MutexHandle mutexHandle) = 0;
00326     
00333     virtual SAPDB_Bool releaseMutex(MutexHandle mutexHandle) = 0;
00334     
00343     virtual SAPDB_Bool destroyMutex(MutexHandle& mutexHandle, 
00344                                     SAPDBMem_IRawAllocator& allocator,
00345                                     Msg_List& errorMessages) = 0;
00346     
00355     virtual SAPDB_Bool  createCounter(CounterHandle& counterHandle,
00356                                       SAPDBMem_IRawAllocator& allocator,
00357                                       Msg_List& errorMessages)  = 0;
00358 
00359     
00365     virtual SAPDB_UInt4 nextCounter(CounterHandle counterHandle) = 0;
00366     
00376     virtual SAPDB_Bool  destroyCounter(CounterHandle counterHandle,
00377                                       SAPDBMem_IRawAllocator& allocator,
00378                                       Msg_List& errorMessages)  = 0;
00379            
00386     virtual TaskID getCurrentTaskID() = 0;                                      
00387                                       
00397     virtual SAPDB_Bool createSemaphore(SemaphoreHandle& semaphoreHandle,
00398                                        SAPDB_Int4 initialValue,
00399                                        SAPDBMem_IRawAllocator& allocator,
00400                                        Msg_List& errorMessages) = 0;
00401 
00409     virtual SAPDB_Bool waitSemaphore(SemaphoreHandle semaphoreHandle) =0;
00410 
00417     virtual SAPDB_Bool signalSemaphore(SemaphoreHandle semaphoreHandle) =0;
00418     
00428     virtual SAPDB_Bool destroySemaphore(SemaphoreHandle& semaphoreHandle,
00429                                         SAPDBMem_IRawAllocator& allocator,
00430                                         Msg_List& errorMessages)  = 0;
00431     
00432     // -- Tracing 
00433     
00441     virtual TaskTraceContext* getTaskTraceContext() = 0;
00442     
00449     virtual void write(const char *s, SAPDB_Int4 size) = 0;
00450     
00457     virtual void writeln(const char *s, SAPDB_Int4 size) = 0;
00458     
00468     virtual void updateTraceFlags(SAPDB_Bool& traceEnabled) { traceEnabled=true; return; }
00469 
00476     virtual SAPDB_Bool traceError(SAPDB_Int4 errorcode) { return false; }
00477 
00478     //-- internally for client runtime used, no use in Kernel/OMS/...
00479     
00480     virtual void setTraceOptions(const char *optionstring) 
00481     { 
00482         return; 
00483     }
00484     
00485     virtual SAPDB_Int4 getTraceOptions(char *options, SAPDB_Int4 optionslength) 
00486     { 
00487         if(options && optionslength>0) {
00488             *options = '\0';
00489         }
00490         return 0; 
00491     }
00492 
00493 };
00494 
00495 #endif
00496