00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00055 #ifndef __vtkSQLDatabase_h
00056 #define __vtkSQLDatabase_h
00057
00058 #include "vtkObject.h"
00059
00060 #include "vtkStdString.h"
00061
00062 class vtkSQLDatabaseSchema;
00063 class vtkSQLQuery;
00064 class vtkStringArray;
00065
00066
00067
00068
00069 #define VTK_SQL_FEATURE_TRANSACTIONS 1000
00070 #define VTK_SQL_FEATURE_QUERY_SIZE 1001
00071 #define VTK_SQL_FEATURE_BLOB 1002
00072 #define VTK_SQL_FEATURE_UNICODE 1003
00073 #define VTK_SQL_FEATURE_PREPARED_QUERIES 1004
00074 #define VTK_SQL_FEATURE_NAMED_PLACEHOLDERS 1005
00075 #define VTK_SQL_FEATURE_POSITIONAL_PLACEHOLDERS 1006
00076 #define VTK_SQL_FEATURE_LAST_INSERT_ID 1007
00077 #define VTK_SQL_FEATURE_BATCH_OPERATIONS 1008
00078 #define VTK_SQL_FEATURE_TRIGGERS 1009 // supported
00079
00080
00081
00082 #define VTK_SQL_DEFAULT_COLUMN_SIZE 32
00083
00084 class VTK_IO_EXPORT vtkSQLDatabase : public vtkObject
00085 {
00086 public:
00087 vtkTypeRevisionMacro(vtkSQLDatabase, vtkObject);
00088 void PrintSelf(ostream& os, vtkIndent indent);
00089
00095 virtual bool Open(const char* password) = 0;
00096
00098 virtual void Close() = 0;
00099
00101 virtual bool IsOpen() = 0;
00102
00104 virtual vtkSQLQuery* GetQueryInstance() = 0;
00105
00107 virtual bool HasError() = 0;
00108
00113 virtual const char* GetLastErrorText() = 0;
00114
00116 virtual char* GetDatabaseType() = 0;
00117
00119 virtual vtkStringArray* GetTables() = 0;
00120
00122 virtual vtkStringArray* GetRecord(const char *table) = 0;
00123
00125 virtual bool IsSupported(int vtkNotUsed(feature)) { return false; }
00126
00128 virtual vtkStdString GetURL() = 0;
00129
00134 virtual vtkStdString GetTablePreamble( bool ) { return vtkStdString(); }
00135
00137
00142 virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
00143 int tblHandle,
00144 int colHandle );
00146
00148
00157 virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
00158 int tblHandle,
00159 int idxHandle,
00160 bool& skipped );
00162
00164
00172 virtual vtkStdString GetTriggerSpecification( vtkSQLDatabaseSchema* schema,
00173 int tblHandle,
00174 int trgHandle );
00176
00181 static vtkSQLDatabase* CreateFromURL( const char* URL );
00182
00184 virtual bool EffectSchema( vtkSQLDatabaseSchema*, bool dropIfExists = false );
00185
00186
00188 typedef vtkSQLDatabase* (*CreateFunction)(const char* URL);
00189
00190
00192
00196 static void RegisterCreateFromURLCallback(CreateFunction callback);
00197 static void UnRegisterCreateFromURLCallback(CreateFunction callback);
00198 static void UnRegisterAllCreateFromURLCallbacks();
00200
00201
00202 protected:
00203 vtkSQLDatabase();
00204 ~vtkSQLDatabase();
00205
00210 virtual bool ParseURL( const char* url ) = 0;
00211
00212 private:
00213 vtkSQLDatabase(const vtkSQLDatabase &);
00214 void operator=(const vtkSQLDatabase &);
00215
00217
00218 class vtkCallbackVector;
00219 static vtkCallbackVector* Callbacks;
00221
00222 };
00223
00224 #endif // __vtkSQLDatabase_h