VTK  9.2.6
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#include "vtkDeprecation.h" // For deprecation macros
35#include "vtkGUISupportQtSQLModule.h" // For export macro
36#include "vtkSQLDatabase.h"
37
38#include <QtSql/QSqlDatabase> // For the database member
39
40class vtkSQLQuery;
41class vtkStringArray;
42
43class VTKGUISUPPORTQTSQL_EXPORT vtkQtSQLDatabase : public vtkSQLDatabase
44{
45public:
48 void PrintSelf(ostream& os, vtkIndent indent) override;
49
55 bool Open(const char* password) override;
56
60 void Close() override;
61
65 bool IsOpen() override;
66
71
76
80 vtkStringArray* GetRecord(const char* table) override;
81
88
94 void SetColumnsTable(const char* table);
95
99 bool IsSupported(int feature) override;
100
104 bool HasError() override;
105
109 const char* GetLastErrorText() override;
110
112
115 const char* GetDatabaseType() override { return this->DatabaseType; }
116 vtkSetStringMacro(DatabaseType);
118
120
123 vtkSetStringMacro(HostName);
124 vtkGetStringMacro(HostName);
126
128
131 vtkSetStringMacro(UserName);
132 vtkGetStringMacro(UserName);
134
136
139 vtkSetStringMacro(DatabaseName);
140 vtkGetStringMacro(DatabaseName);
142
144
147 vtkSetStringMacro(ConnectOptions);
148 vtkGetStringMacro(ConnectOptions);
150
151 // VTK_DEPRECATED_IN_9_1_0: Remove header test exclusion when this is removed.
153 VTK_DEPRECATED_IN_9_1_0("Renamed to DbPort to avoid Windows macro collisions")
154 void SetPort(int port) { this->SetDbPort(port); }
155 VTK_DEPRECATED_IN_9_1_0("Renamed to DbPort to avoid Windows macro collisions")
156 int GetPort() { return this->GetDbPort(); }
158
160
163 vtkSetClampMacro(DbPort, int, 0, 65535);
164 vtkGetMacro(DbPort, int);
166
172 static vtkSQLDatabase* CreateFromURL(const char* URL);
173
178
179protected:
182
184 char* HostName;
185 char* UserName;
189
190 QSqlDatabase QtDatabase;
191
192 friend class vtkQtSQLQuery;
193
199 bool ParseURL(const char* url) override;
200
201private:
202 // Storing the tables in the database, this array
203 // is accessible through GetTables() method
204 vtkStringArray* myTables;
205
206 // Storing the correct record list from any one
207 // of the tables in the database, this array is
208 // accessible through GetRecord(const char *table)
209 vtkStringArray* currentRecord;
210
211 // Used to assign unique identifiers for database instances
212 static int id;
213
214 vtkQtSQLDatabase(const vtkQtSQLDatabase&) = delete;
215 void operator=(const vtkQtSQLDatabase&) = delete;
216};
217
218#endif // vtkQtSQLDatabase_h
219// VTK-HeaderTest-Exclude: vtkQtSQLDatabase.h
a simple class to control print indentation
Definition: vtkIndent.h:40
maintains a connection to an sql database
vtkStringArray * GetTables() override
Get the list of tables from the database.
const char * GetDatabaseType() override
String representing Qt database type (e.g.
bool Open(const char *password) override
Open a new connection to the database.
bool IsOpen() override
Return whether the database has an open connection.
vtkStringArray * GetColumns()
Returns a list of columns for a particular table.
vtkStdString GetURL() override
Get the URL of the database.
vtkSQLQuery * GetQueryInstance() override
Return an empty query on this database.
bool HasError() override
Did the last operation generate an error.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkSQLDatabase * CreateFromURL(const char *URL)
Create a the proper subclass given a URL.
bool IsSupported(int feature) override
Return whether a feature is supported by the database.
void SetColumnsTable(const char *table)
Set the table used by GetColumns() Note that this is mainly for use with the VTK parallel server.
const char * GetLastErrorText() override
Get the last error text from the database.
~vtkQtSQLDatabase() override
bool ParseURL(const char *url) override
Overridden to determine connection parameters given the URL.
vtkStringArray * GetRecord(const char *table) override
Get the list of fields for a particular table.
QSqlDatabase QtDatabase
static vtkQtSQLDatabase * New()
void Close() override
Close the connection to the database.
query class associated with vtkQtSQLDatabase
Definition: vtkQtSQLQuery.h:38
maintain a connection to an sql database
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:75
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:39
a vtkAbstractArray subclass for strings
#define VTK_DEPRECATED_IN_9_1_0(reason)