VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkQtSQLDatabase.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 -------------------------------------------------------------------------*/ 00030 #ifndef __vtkQtSQLDatabase_h 00031 #define __vtkQtSQLDatabase_h 00032 00033 // Check for Qt SQL module before defining this class. 00034 #include <qglobal.h> 00035 #if (QT_EDITION & QT_MODULE_SQL) 00036 00037 #include "vtkGUISupportQtSQLModule.h" 00038 #include "vtkSQLDatabase.h" 00039 00040 #include <QtSql/QSqlDatabase> 00041 00042 class vtkSQLQuery; 00043 class vtkStringArray; 00044 00045 class VTKGUISUPPORTQTSQL_EXPORT vtkQtSQLDatabase : public vtkSQLDatabase 00046 { 00047 public: 00048 static vtkQtSQLDatabase* New(); 00049 vtkTypeMacro(vtkQtSQLDatabase, vtkSQLDatabase); 00050 void PrintSelf(ostream& os, vtkIndent indent); 00051 00055 virtual bool Open(const char* password); 00056 00058 virtual void Close(); 00059 00061 virtual bool IsOpen(); 00062 00064 virtual vtkSQLQuery* GetQueryInstance(); 00065 00067 vtkStringArray* GetTables(); 00068 00070 vtkStringArray* GetRecord(const char *table); 00071 00075 vtkStringArray* GetColumns(); 00076 00080 void SetColumnsTable(const char* table); 00081 00083 virtual bool IsSupported(int feature); 00084 00086 bool HasError(); 00087 00089 const char* GetLastErrorText(); 00090 00092 00093 vtkGetStringMacro(DatabaseType); 00094 vtkSetStringMacro(DatabaseType); 00096 00098 00099 vtkSetStringMacro(HostName); 00100 vtkGetStringMacro(HostName); 00102 00104 00105 vtkSetStringMacro(UserName); 00106 vtkGetStringMacro(UserName); 00108 00110 00111 vtkSetStringMacro(DatabaseName); 00112 vtkGetStringMacro(DatabaseName); 00114 00116 00117 vtkSetStringMacro(ConnectOptions); 00118 vtkGetStringMacro(ConnectOptions); 00120 00122 00123 vtkSetClampMacro(Port, int, 0, VTK_INT_MAX); 00124 vtkGetMacro(Port, int); 00126 00131 static vtkSQLDatabase* CreateFromURL( const char* URL ); 00132 00134 virtual vtkStdString GetURL(); 00135 00136 protected: 00137 vtkQtSQLDatabase(); 00138 ~vtkQtSQLDatabase(); 00139 00140 char* DatabaseType; 00141 char* HostName; 00142 char* UserName; 00143 char* DatabaseName; 00144 int Port; 00145 char* ConnectOptions; 00146 00147 QSqlDatabase QtDatabase; 00148 00149 friend class vtkQtSQLQuery; 00150 00152 00155 virtual bool ParseURL(const char* url); 00156 private: 00158 00159 // Storing the tables in the database, this array 00160 // is accessible through GetTables() method 00161 vtkStringArray *myTables; 00162 00163 // Storing the currect record list from any one 00164 // of the tables in the database, this array is 00165 // accessible through GetRecord(const char *table) 00166 vtkStringArray *currentRecord; 00167 00168 // Used to assign unique identifiers for database instances 00169 static int id; 00170 00171 vtkQtSQLDatabase(const vtkQtSQLDatabase &); // Not implemented. 00172 void operator=(const vtkQtSQLDatabase &); // Not implemented. 00173 }; 00174 00175 #endif // (QT_EDITION & QT_MODULE_SQL) 00176 #endif // __vtkQtSQLDatabase_h 00177