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 vtkInformationObjectBaseKey;
00063 class vtkSQLDatabaseSchema;
00064 class vtkSQLQuery;
00065 class vtkStringArray;
00066
00067
00068
00069
00070 #define VTK_SQL_FEATURE_TRANSACTIONS 1000
00071 #define VTK_SQL_FEATURE_QUERY_SIZE 1001
00072 #define VTK_SQL_FEATURE_BLOB 1002
00073 #define VTK_SQL_FEATURE_UNICODE 1003
00074 #define VTK_SQL_FEATURE_PREPARED_QUERIES 1004
00075 #define VTK_SQL_FEATURE_NAMED_PLACEHOLDERS 1005
00076 #define VTK_SQL_FEATURE_POSITIONAL_PLACEHOLDERS 1006
00077 #define VTK_SQL_FEATURE_LAST_INSERT_ID 1007
00078 #define VTK_SQL_FEATURE_BATCH_OPERATIONS 1008
00079 #define VTK_SQL_FEATURE_TRIGGERS 1009 // supported
00080
00081
00082
00083 #define VTK_SQL_DEFAULT_COLUMN_SIZE 32
00084
00085 class VTK_IO_EXPORT vtkSQLDatabase : public vtkObject
00086 {
00087 public:
00088 vtkTypeRevisionMacro(vtkSQLDatabase, vtkObject);
00089 void PrintSelf(ostream& os, vtkIndent indent);
00090
00096 virtual bool Open(const char* password) = 0;
00097
00099 virtual void Close() = 0;
00100
00102 virtual bool IsOpen() = 0;
00103
00105 virtual vtkSQLQuery* GetQueryInstance() = 0;
00106
00108 virtual bool HasError() = 0;
00109
00114 virtual const char* GetLastErrorText() = 0;
00115
00117 virtual char* GetDatabaseType() = 0;
00118
00120 virtual vtkStringArray* GetTables() = 0;
00121
00123 virtual vtkStringArray* GetRecord(const char *table) = 0;
00124
00126 virtual bool IsSupported(int vtkNotUsed(feature)) { return false; }
00127
00129 virtual vtkStdString GetURL() = 0;
00130
00135 virtual vtkStdString GetTablePreamble( bool ) { return vtkStdString(); }
00136
00138
00143 virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
00144 int tblHandle,
00145 int colHandle );
00147
00149
00158 virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
00159 int tblHandle,
00160 int idxHandle,
00161 bool& skipped );
00163
00165
00173 virtual vtkStdString GetTriggerSpecification( vtkSQLDatabaseSchema* schema,
00174 int tblHandle,
00175 int trgHandle );
00177
00182 static vtkSQLDatabase* CreateFromURL( const char* URL );
00183
00185 virtual bool EffectSchema( vtkSQLDatabaseSchema*, bool dropIfExists = false );
00186
00187
00189 typedef vtkSQLDatabase* (*CreateFunction)(const char* URL);
00190
00191
00193
00197 static void RegisterCreateFromURLCallback(CreateFunction callback);
00198 static void UnRegisterCreateFromURLCallback(CreateFunction callback);
00199 static void UnRegisterAllCreateFromURLCallbacks();
00201
00209 static vtkInformationObjectBaseKey* DATABASE();
00210
00211
00212 protected:
00213 vtkSQLDatabase();
00214 ~vtkSQLDatabase();
00215
00220 virtual bool ParseURL( const char* url ) = 0;
00221
00222 private:
00223 vtkSQLDatabase(const vtkSQLDatabase &);
00224 void operator=(const vtkSQLDatabase &);
00225
00227
00228 class vtkCallbackVector;
00229 static vtkCallbackVector* Callbacks;
00231
00232 };
00233
00234 #endif // __vtkSQLDatabase_h