VTK
vtkQtSQLDatabase.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkQtSQLDatabase.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15/*-------------------------------------------------------------------------
16 Copyright 2008 Sandia Corporation.
17 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18 the U.S. Government retains certain rights in this software.
19-------------------------------------------------------------------------*/
31#ifndef vtkQtSQLDatabase_h
32#define vtkQtSQLDatabase_h
33
34// Check for Qt SQL module before defining this class.
35#include <qglobal.h> // Needed to check if SQL is available
36#if (QT_EDITION & QT_MODULE_SQL)
37
38#include "vtkGUISupportQtSQLModule.h" // For export macro
39#include "vtkSQLDatabase.h"
40
41#include <QtSql/QSqlDatabase> // For the database member
42
43class vtkSQLQuery;
44class vtkStringArray;
45
46class VTKGUISUPPORTQTSQL_EXPORT vtkQtSQLDatabase : public vtkSQLDatabase
47{
48public:
49 static vtkQtSQLDatabase* New();
50 vtkTypeMacro(vtkQtSQLDatabase, vtkSQLDatabase);
51 void PrintSelf(ostream& os, vtkIndent indent);
52
58 virtual bool Open(const char* password);
59
63 virtual void Close();
64
68 virtual bool IsOpen();
69
74
79
83 vtkStringArray* GetRecord(const char *table);
84
90 vtkStringArray* GetColumns();
91
97 void SetColumnsTable(const char* table);
98
102 virtual bool IsSupported(int feature);
103
107 bool HasError();
108
112 const char* GetLastErrorText();
113
115
118 vtkGetStringMacro(DatabaseType);
119 vtkSetStringMacro(DatabaseType);
121
123
126 vtkSetStringMacro(HostName);
127 vtkGetStringMacro(HostName);
129
131
134 vtkSetStringMacro(UserName);
135 vtkGetStringMacro(UserName);
137
139
142 vtkSetStringMacro(DatabaseName);
143 vtkGetStringMacro(DatabaseName);
145
147
150 vtkSetStringMacro(ConnectOptions);
151 vtkGetStringMacro(ConnectOptions);
153
155
158 vtkSetClampMacro(Port, int, 0, 65535);
159 vtkGetMacro(Port, int);
161
167 static vtkSQLDatabase* CreateFromURL( const char* URL );
168
172 virtual vtkStdString GetURL();
173
174protected:
177
178 char* DatabaseType;
179 char* HostName;
180 char* UserName;
181 char* DatabaseName;
182 int Port;
183 char* ConnectOptions;
184
185 QSqlDatabase QtDatabase;
186
187 friend class vtkQtSQLQuery;
188
194 virtual bool ParseURL(const char* url);
195private:
196
197 // Storing the tables in the database, this array
198 // is accessible through GetTables() method
199 vtkStringArray *myTables;
200
201 // Storing the currect record list from any one
202 // of the tables in the database, this array is
203 // accessible through GetRecord(const char *table)
204 vtkStringArray *currentRecord;
205
206 // Used to assign unique identifiers for database instances
207 static int id;
208
209 vtkQtSQLDatabase(const vtkQtSQLDatabase &) VTK_DELETE_FUNCTION;
210 void operator=(const vtkQtSQLDatabase &) VTK_DELETE_FUNCTION;
211};
212
213#endif // (QT_EDITION & QT_MODULE_SQL)
214#endif // vtkQtSQLDatabase_h
215
a simple class to control print indentation
Definition: vtkIndent.h:40
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
maintains a connection to an sql database
query class associated with vtkQtSQLDatabase
maintain a connection to an sql database
virtual bool Open(const char *password)=0
Open a new connection to the database.
virtual vtkStringArray * GetRecord(const char *table)=0
Get the list of fields for a particular table.
virtual vtkStdString GetURL()=0
Get the URL of the database.
virtual VTK_NEWINSTANCE vtkSQLQuery * GetQueryInstance()=0
Return an empty query on this database.
virtual bool ParseURL(const char *url)=0
Subclasses should override this method to determine connection parameters given the URL.
static VTK_NEWINSTANCE vtkSQLDatabase * CreateFromURL(const char *URL)
Create a the proper subclass given a URL.
virtual bool HasError()=0
Did the last operation generate an error.
virtual bool IsSupported(int vtkNotUsed(feature))
Return whether a feature is supported by the database.
virtual void Close()=0
Close the connection to the database.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual const char * GetLastErrorText()=0
Get the last error text from the database I'm using const so that people do NOT use the standard vtkG...
virtual vtkStringArray * GetTables()=0
Get the list of tables from the database.
virtual bool IsOpen()=0
Return whether the database has an open connection.
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:75
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
a vtkAbstractArray subclass for strings
@ url
Definition: vtkX3D.h:233
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.