00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00038 #ifndef __vtkMySQLDatabase_h
00039 #define __vtkMySQLDatabase_h
00040
00041 #include "vtkSQLDatabase.h"
00042
00043 class vtkSQLQuery;
00044 class vtkMySQLQuery;
00045 class vtkStringArray;
00046 class vtkMySQLDatabasePrivate;
00047
00048 class VTK_IO_EXPORT vtkMySQLDatabase : public vtkSQLDatabase
00049 {
00050
00051 friend class vtkMySQLQuery;
00052
00053
00054 public:
00055 vtkTypeMacro(vtkMySQLDatabase, vtkSQLDatabase);
00056 void PrintSelf(ostream& os, vtkIndent indent);
00057 static vtkMySQLDatabase *New();
00058
00062 bool Open( const char* password = 0 );
00063
00065 void Close();
00066
00068 bool IsOpen();
00069
00071 vtkSQLQuery* GetQueryInstance();
00072
00074 vtkStringArray* GetTables();
00075
00077 vtkStringArray* GetRecord(const char *table);
00078
00080 bool IsSupported(int feature);
00081
00083 bool HasError();
00084
00086 const char* GetLastErrorText();
00087
00089
00090 vtkGetStringMacro(DatabaseType);
00092
00094
00095 vtkSetStringMacro(HostName);
00096 vtkGetStringMacro(HostName);
00098
00100
00101 vtkSetStringMacro(User);
00102 vtkGetStringMacro(User);
00104
00106
00107 vtkSetStringMacro(Password);
00109
00111
00112 vtkSetStringMacro(DatabaseName);
00113 vtkGetStringMacro(DatabaseName);
00115
00117
00119 vtkSetMacro(Reconnect,int);
00120 vtkGetMacro(Reconnect,int);
00121 vtkBooleanMacro(Reconnect,int);
00123
00125
00126 vtkSetClampMacro(ServerPort, int, 0, VTK_INT_MAX);
00127 vtkGetMacro(ServerPort, int);
00129
00131 virtual vtkStdString GetURL();
00132
00136 virtual vtkStdString GetTablePreamble( bool b ) { return b ? vtkStdString() :"IF NOT EXISTS "; }
00137
00139
00146 virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
00147 int tblHandle,
00148 int colHandle );
00150
00152
00158 virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
00159 int tblHandle,
00160 int idxHandle,
00161 bool& skipped );
00163
00167 bool CreateDatabase( const char* dbName, bool dropExisting );
00168
00171 bool DropDatabase( const char* dbName );
00172
00173 protected:
00174 vtkMySQLDatabase();
00175 ~vtkMySQLDatabase();
00176
00180 virtual bool ParseURL(const char* url);
00181
00182 private:
00183
00184
00185 vtkSetStringMacro(DatabaseType);
00186
00187 vtkStringArray *Tables;
00188 vtkStringArray *Record;
00189
00190 char* DatabaseType;
00191 char* HostName;
00192 char* User;
00193 char* Password;
00194 char* DatabaseName;
00195 int ServerPort;
00196 int Reconnect;
00197
00198
00199 vtkMySQLDatabasePrivate* const Private;
00200
00201
00202 vtkMySQLDatabase(const vtkMySQLDatabase &);
00203 void operator=(const vtkMySQLDatabase &);
00204 };
00205
00206 #endif // __vtkMySQLDatabase_h
00207