00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00058 #ifndef __vtkSQLDatabase_h
00059 #define __vtkSQLDatabase_h
00060
00061 #include "vtkObject.h"
00062
00063 #include "vtkStdString.h"
00064
00065 class vtkInformationObjectBaseKey;
00066 class vtkSQLDatabaseSchema;
00067 class vtkSQLQuery;
00068 class vtkStringArray;
00069
00070
00071
00072
00073 #define VTK_SQL_FEATURE_TRANSACTIONS 1000
00074 #define VTK_SQL_FEATURE_QUERY_SIZE 1001
00075 #define VTK_SQL_FEATURE_BLOB 1002
00076 #define VTK_SQL_FEATURE_UNICODE 1003
00077 #define VTK_SQL_FEATURE_PREPARED_QUERIES 1004
00078 #define VTK_SQL_FEATURE_NAMED_PLACEHOLDERS 1005
00079 #define VTK_SQL_FEATURE_POSITIONAL_PLACEHOLDERS 1006
00080 #define VTK_SQL_FEATURE_LAST_INSERT_ID 1007
00081 #define VTK_SQL_FEATURE_BATCH_OPERATIONS 1008
00082 #define VTK_SQL_FEATURE_TRIGGERS 1009 // supported
00083
00084
00085
00086 #define VTK_SQL_DEFAULT_COLUMN_SIZE 32
00087
00088 class VTK_IO_EXPORT vtkSQLDatabase : public vtkObject
00089 {
00090 public:
00091 vtkTypeMacro(vtkSQLDatabase, vtkObject);
00092 void PrintSelf(ostream& os, vtkIndent indent);
00093
00099 virtual bool Open(const char* password) = 0;
00100
00102 virtual void Close() = 0;
00103
00105 virtual bool IsOpen() = 0;
00106
00108 virtual vtkSQLQuery* GetQueryInstance() = 0;
00109
00111 virtual bool HasError() = 0;
00112
00117 virtual const char* GetLastErrorText() = 0;
00118
00120 virtual char* GetDatabaseType() = 0;
00121
00123 virtual vtkStringArray* GetTables() = 0;
00124
00126 virtual vtkStringArray* GetRecord(const char *table) = 0;
00127
00129 virtual bool IsSupported(int vtkNotUsed(feature)) { return false; }
00130
00132 virtual vtkStdString GetURL() = 0;
00133
00138 virtual vtkStdString GetTablePreamble( bool ) { return vtkStdString(); }
00139
00141
00146 virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
00147 int tblHandle,
00148 int colHandle );
00150
00152
00161 virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
00162 int tblHandle,
00163 int idxHandle,
00164 bool& skipped );
00166
00168
00176 virtual vtkStdString GetTriggerSpecification( vtkSQLDatabaseSchema* schema,
00177 int tblHandle,
00178 int trgHandle );
00180
00185 static vtkSQLDatabase* CreateFromURL( const char* URL );
00186
00188 virtual bool EffectSchema( vtkSQLDatabaseSchema*, bool dropIfExists = false );
00189
00190
00192 typedef vtkSQLDatabase* (*CreateFunction)(const char* URL);
00193
00194
00196
00200 static void RegisterCreateFromURLCallback(CreateFunction callback);
00201 static void UnRegisterCreateFromURLCallback(CreateFunction callback);
00202 static void UnRegisterAllCreateFromURLCallbacks();
00204
00212 static vtkInformationObjectBaseKey* DATABASE();
00213
00214
00215 protected:
00216 vtkSQLDatabase();
00217 ~vtkSQLDatabase();
00218
00223 virtual bool ParseURL( const char* url ) = 0;
00224
00225 private:
00226 vtkSQLDatabase(const vtkSQLDatabase &);
00227 void operator=(const vtkSQLDatabase &);
00228
00230
00231 class vtkCallbackVector;
00232 static vtkCallbackVector* Callbacks;
00234
00235 };
00236
00237 #endif // __vtkSQLDatabase_h