Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound 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 
00039 class SAPDBMem_IRawAllocator;
00040 class SAPDBErr_MessageList;
00041 
00042 #ifdef _WIN32 
00043 #define SQLDBC_DLLEXPORT __declspec(dllexport)
00044 #else
00045 #define SQLDBC_DLLEXPORT
00046 #endif
00047   
00091 class SQLDBC_IRuntime
00092 {
00093 public:
00097     typedef void *MutexHandle;
00098 
00102     typedef void *SemaphoreHandle;
00103 
00107     typedef void *CounterHandle;
00108 
00112     struct TaskTraceContext
00113     {
00114         void           *currentEntry;   
00115         // -- further settings, used by the trace stream abstraction.
00116         SAPDB_Bool  hex;               
00117         SAPDB_UInt4 inputlength;       
00118         SQLDBC_StringEncoding encoding;
00119         SAPDB_UInt4 indent;            
00120         SAPDB_UInt4 flags;             
00121         SAPDB_UInt4 traceableLimit;    
00122         SAPDB_UInt4 pos;               
00123     };
00124         
00128     typedef SAPDB_UInt4 TaskID;
00129 
00133     virtual ~SQLDBC_IRuntime() {}
00134 
00140     virtual const char *getIdentifier() const { return ""; }
00141 
00168     virtual SAPDB_Bool checkKeyOption(const char *keyoption,
00169                                       char *servernode,
00170                                       SAPDB_Int4& servernodelength,
00171                                       char *serverdb,
00172                                       SAPDB_Int4& serverdblength,
00173                                       SAPDB_Int4& isolationlevel,
00174                                       SAPDB_Int4& cachelimit,
00175                                       SAPDB_Int4& sqlmode,
00176                                       SAPDB_Int4& timeout,
00177                                       char *username,
00178                                       SAPDB_Int4& usernamelength,
00179                                       SQLDBC_StringEncoding& usernameEncoding,
00180                                       SAPDBErr_MessageList& errorMessages)
00181     {
00182         return false;
00183     }
00184                                   
00185 
00186     
00197     virtual SAPDBMem_IRawAllocator& getGlobalAllocator() = 0;
00198 
00199     // Packet and Session Handling
00200 
00238     virtual SAPDB_Bool getSession(const char *connectUrl,
00239                                   const char *connectCommand,
00240                                   const char *password,
00241                                   SAPDB_Int4  passwordLength,
00242                                   const SQLDBC_StringEncoding commandEncoding,
00243                                   SAPDB_Int8&  sessionID,
00244                                   SAPDB_UInt4& packetSize,
00245                                   SAPDB_Int4& packetListSize,
00246                                   void **packetList,  
00247                                   void **sessionInfoReply,
00248                                   SAPDBErr_MessageList& errorMessages,
00249                                   SAPDBMem_IRawAllocator* allocator = 0) = 0;
00250 
00259     virtual SAPDB_Bool releaseSession(SAPDB_Int8 sessionID,
00260                                       SAPDBErr_MessageList& errorMessages) = 0;
00261     
00272     virtual SAPDB_Bool request(SAPDB_Int8  sessionID,
00273                                void       *requestData,
00274                                SAPDB_UInt4 requestDataLength,
00275                                SAPDBErr_MessageList& errorMessages) = 0; 
00276 
00286     virtual SAPDB_Bool receive(SAPDB_Int8 sessionID,
00287                                void **replyData,
00288                                SAPDB_Int4& replyDataLength,
00289                                SAPDBErr_MessageList& errorMessages) = 0;
00290 
00298     virtual SAPDB_Bool cancelCurrentCommand(SAPDB_Int8 sessionID,
00299                                             SAPDBErr_MessageList& errorMessages) = 0;
00300 
00301     // -- synchronization primitives
00311     virtual SAPDB_Bool createMutex(MutexHandle& mutexHandle, 
00312                                    SAPDBMem_IRawAllocator& allocator,
00313                                    SAPDBErr_MessageList& errorMessages)  = 0;
00314 
00321     virtual SAPDB_Bool lockMutex(MutexHandle mutexHandle) = 0;
00322     
00329     virtual SAPDB_Bool releaseMutex(MutexHandle mutexHandle) = 0;
00330     
00339     virtual SAPDB_Bool destroyMutex(MutexHandle& mutexHandle, 
00340                                     SAPDBMem_IRawAllocator& allocator,
00341                                     SAPDBErr_MessageList& errorMessages) = 0;
00342     
00351     virtual SAPDB_Bool  createCounter(CounterHandle& counterHandle,
00352                                       SAPDBMem_IRawAllocator& allocator,
00353                                       SAPDBErr_MessageList& errorMessages)  = 0;
00354 
00355     
00361     virtual SAPDB_UInt4 nextCounter(CounterHandle counterHandle) = 0;
00362     
00372     virtual SAPDB_Bool  destroyCounter(CounterHandle counterHandle,
00373                                       SAPDBMem_IRawAllocator& allocator,
00374                                       SAPDBErr_MessageList& errorMessages)  = 0;
00375            
00382     virtual TaskID getCurrentTaskID() = 0;                                      
00383                                       
00393     virtual SAPDB_Bool createSemaphore(SemaphoreHandle& semaphoreHandle,
00394                                        SAPDB_Int4 initialValue,
00395                                        SAPDBMem_IRawAllocator& allocator,
00396                                        SAPDBErr_MessageList& errorMessages) = 0;
00397 
00405     virtual SAPDB_Bool waitSemaphore(SemaphoreHandle semaphoreHandle) =0;
00406 
00413     virtual SAPDB_Bool signalSemaphore(SemaphoreHandle semaphoreHandle) =0;
00414     
00424     virtual SAPDB_Bool destroySemaphore(SemaphoreHandle& semaphoreHandle,
00425                                         SAPDBMem_IRawAllocator& allocator,
00426                                         SAPDBErr_MessageList& errorMessages)  = 0;
00427     
00428     // -- Tracing 
00429     
00437     virtual TaskTraceContext* getTaskTraceContext() = 0;
00438     
00445     virtual void write(const char *s, SAPDB_Int4 size) = 0;
00446     
00453     virtual void writeln(const char *s, SAPDB_Int4 size) = 0;
00454     
00464     virtual void updateTraceFlags(SAPDB_Bool& traceEnabled) { traceEnabled=true; return; }
00465 };
00466 
00467 #endif
00468