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 
00032 #ifndef SQLDBC_IRUNTIME_H
00033 #define SQLDBC_IRUNTIME_H
00034 
00035 // For encoding
00036 #include "Interfaces/SQLDBC/SQLDBC_Types.h"
00037 #include "SAPDBCommon/SAPDB_Types.h"
00038 #include "SAPDBCommon/SAPDB_ReuseLib.h"
00039 #include "SAPDB/SAPDBCommon/ErrorsAndMessages/SAPDBErr_MessageList.hpp"
00040 
00041 #ifndef Msg_List
00042 #  define Msg_List SAPDBErr_MessageList
00043 #endif
00044 
00045 class SAPDBMem_IRawAllocator;
00046 
00047 #ifdef _WIN32 
00048 #define SQLDBC_DLLEXPORT __declspec(dllexport)
00049 #else
00050 #define SQLDBC_DLLEXPORT
00051 #endif
00052   
00096 class SQLDBC_IRuntime
00097 {
00098 public:
00102     typedef void *MutexHandle;
00103 
00107     typedef void *SemaphoreHandle;
00108 
00112     typedef void *CounterHandle;
00113 
00117     struct TaskTraceContext
00118     {
00119         void           *currentEntry;   
00120         // -- further settings, used by the trace stream abstraction.
00121         SAPDB_Bool  hex;               
00122         SAPDB_UInt4 inputlength;       
00123         SQLDBC_StringEncoding encoding;
00124         SAPDB_UInt4 indent;            
00125         SAPDB_UInt4 flags;             
00126         SAPDB_UInt4 traceableLimit;    
00127         SAPDB_UInt4 pos;               
00128     };
00129         
00133     typedef SAPDB_UInt4 TaskID;
00134 
00138     virtual ~SQLDBC_IRuntime() {}
00139 
00145     virtual const char *getIdentifier() const { return ""; }
00146 
00173     virtual SAPDB_Bool checkKeyOption(const char *keyoption,
00174                                       char *servernode,
00175                                       SAPDB_Int4& servernodelength,
00176                                       char *serverdb,
00177                                       SAPDB_Int4& serverdblength,
00178                                       SAPDB_Int4& isolationlevel,
00179                                       SAPDB_Int4& cachelimit,
00180                                       SAPDB_Int4& sqlmode,
00181                                       SAPDB_Int4& timeout,
00182                                       char *username,
00183                                       SAPDB_Int4& usernamelength,
00184                                       SQLDBC_StringEncoding& usernameEncoding,
00185                                       Msg_List& errorMessages)
00186     {
00187         return false;
00188     }
00189                                   
00190 
00191     
00202     virtual SAPDBMem_IRawAllocator& getGlobalAllocator() = 0;
00203 
00204     // Packet and Session Handling
00205 
00243     virtual SAPDB_Bool getSession(const char *connectUrl,
00244                                   const char *connectCommand,
00245                                   const char *password,
00246                                   SAPDB_Int4  passwordLength,
00247                                   const SQLDBC_StringEncoding commandEncoding,
00248                                   SAPDB_Int8&  sessionID,
00249                                   SAPDB_UInt4& packetSize,
00250                                   SAPDB_Int4& packetListSize,
00251                                   void **packetList,  
00252                                   void **sessionInfoReply,
00253                                   Msg_List& errorMessages,
00254                                   SAPDBMem_IRawAllocator* allocator = 0) = 0;
00255 
00264     virtual SAPDB_Bool releaseSession(SAPDB_Int8 sessionID,
00265                                       Msg_List& errorMessages) = 0;
00266     
00277     virtual SAPDB_Bool request(SAPDB_Int8  sessionID,
00278                                void       *requestData,
00279                                SAPDB_UInt4 requestDataLength,
00280                                Msg_List& errorMessages) = 0; 
00281 
00291     virtual SAPDB_Bool receive(SAPDB_Int8 sessionID,
00292                                void **replyData,
00293                                SAPDB_Int4& replyDataLength,
00294                                Msg_List& errorMessages) = 0;
00295 
00303     virtual SAPDB_Bool cancelCurrentCommand(SAPDB_Int8 sessionID,
00304                                             Msg_List& errorMessages) = 0;
00305 
00306     // -- synchronization primitives
00316     virtual SAPDB_Bool createMutex(MutexHandle& mutexHandle, 
00317                                    SAPDBMem_IRawAllocator& allocator,
00318                                    Msg_List& errorMessages)  = 0;
00319 
00326     virtual SAPDB_Bool lockMutex(MutexHandle mutexHandle) = 0;
00327     
00334     virtual SAPDB_Bool releaseMutex(MutexHandle mutexHandle) = 0;
00335     
00344     virtual SAPDB_Bool destroyMutex(MutexHandle& mutexHandle, 
00345                                     SAPDBMem_IRawAllocator& allocator,
00346                                     Msg_List& errorMessages) = 0;
00347     
00356     virtual SAPDB_Bool  createCounter(CounterHandle& counterHandle,
00357                                       SAPDBMem_IRawAllocator& allocator,
00358                                       Msg_List& errorMessages)  = 0;
00359 
00360     
00366     virtual SAPDB_UInt4 nextCounter(CounterHandle counterHandle) = 0;
00367     
00377     virtual SAPDB_Bool  destroyCounter(CounterHandle counterHandle,
00378                                       SAPDBMem_IRawAllocator& allocator,
00379                                       Msg_List& errorMessages)  = 0;
00380            
00387     virtual TaskID getCurrentTaskID() = 0;                                      
00388                                       
00398     virtual SAPDB_Bool createSemaphore(SemaphoreHandle& semaphoreHandle,
00399                                        SAPDB_Int4 initialValue,
00400                                        SAPDBMem_IRawAllocator& allocator,
00401                                        Msg_List& errorMessages) = 0;
00402 
00410     virtual SAPDB_Bool waitSemaphore(SemaphoreHandle semaphoreHandle) =0;
00411 
00418     virtual SAPDB_Bool signalSemaphore(SemaphoreHandle semaphoreHandle) =0;
00419     
00429     virtual SAPDB_Bool destroySemaphore(SemaphoreHandle& semaphoreHandle,
00430                                         SAPDBMem_IRawAllocator& allocator,
00431                                         Msg_List& errorMessages)  = 0;
00432     
00433     // -- Tracing 
00434     
00442     virtual TaskTraceContext* getTaskTraceContext() = 0;
00443     
00450     virtual void write(const char *s, SAPDB_Int4 size) = 0;
00451     
00458     virtual void writeln(const char *s, SAPDB_Int4 size) = 0;
00459     
00469     virtual void updateTraceFlags(SAPDB_Bool& traceEnabled) { traceEnabled=true; return; }
00470 
00477     virtual SAPDB_Bool traceError(SAPDB_Int4 errorcode) { return false; }
00478 
00479     //-- internally for client runtime used, no use in Kernel/OMS/...
00480     
00481     virtual void setTraceOptions(const char *optionstring) 
00482     { 
00483         return; 
00484     }
00485     
00486     virtual SAPDB_Int4 getTraceOptions(char *options, SAPDB_Int4 optionslength) 
00487     { 
00488         if(options && optionslength>0) {
00489             *options = '\0';
00490         }
00491         return 0; 
00492     }
00493 
00494 };
00495 
00496 #endif
00497