VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkMySQLDatabase.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 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 //BTX 00051 friend class vtkMySQLQuery; 00052 //ETX 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 00176 virtual bool ParseURL(const char* url); 00177 00178 protected: 00179 vtkMySQLDatabase(); 00180 ~vtkMySQLDatabase(); 00181 00182 private: 00183 // We want this to be private, a user of this class 00184 // should not be setting this for any reason 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 //BTX 00199 vtkMySQLDatabasePrivate* const Private; 00200 //ETX 00201 00202 vtkMySQLDatabase(const vtkMySQLDatabase &); // Not implemented. 00203 void operator=(const vtkMySQLDatabase &); // Not implemented. 00204 }; 00205 00206 #endif // __vtkMySQLDatabase_h 00207