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 -------------------------------------------------------------------------*/
30 #ifndef vtkQtSQLDatabase_h
31 #define vtkQtSQLDatabase_h
32 
33 // Check for Qt SQL module before defining this class.
34 #include <qglobal.h>
35 #if (QT_EDITION & QT_MODULE_SQL)
36 
37 #include "vtkGUISupportQtSQLModule.h"
38 #include "vtkSQLDatabase.h"
39 
40 #include <QtSql/QSqlDatabase>
41 
42 class vtkSQLQuery;
43 class vtkStringArray;
44 
45 class VTKGUISUPPORTQTSQL_EXPORT vtkQtSQLDatabase : public vtkSQLDatabase
46 {
47 public:
48  static vtkQtSQLDatabase* New();
49  vtkTypeMacro(vtkQtSQLDatabase, vtkSQLDatabase);
50  void PrintSelf(ostream& os, vtkIndent indent);
51 
55  virtual bool Open(const char* password);
56 
58  virtual void Close();
59 
61  virtual bool IsOpen();
62 
64  virtual vtkSQLQuery* GetQueryInstance();
65 
68 
70  vtkStringArray* GetRecord(const char *table);
71 
75  vtkStringArray* GetColumns();
76 
80  void SetColumnsTable(const char* table);
81 
83  virtual bool IsSupported(int feature);
84 
86  bool HasError();
87 
89  const char* GetLastErrorText();
90 
92 
93  vtkGetStringMacro(DatabaseType);
94  vtkSetStringMacro(DatabaseType);
96 
98 
99  vtkSetStringMacro(HostName);
100  vtkGetStringMacro(HostName);
102 
104 
105  vtkSetStringMacro(UserName);
106  vtkGetStringMacro(UserName);
108 
110 
111  vtkSetStringMacro(DatabaseName);
112  vtkGetStringMacro(DatabaseName);
114 
116 
117  vtkSetStringMacro(ConnectOptions);
118  vtkGetStringMacro(ConnectOptions);
120 
122 
123  vtkSetClampMacro(Port, int, 0, VTK_INT_MAX);
124  vtkGetMacro(Port, int);
126 
131  static vtkSQLDatabase* CreateFromURL( const char* URL );
132 
134  virtual vtkStdString GetURL();
135 
136 protected:
138  ~vtkQtSQLDatabase();
139 
140  char* DatabaseType;
141  char* HostName;
142  char* UserName;
143  char* DatabaseName;
144  int Port;
145  char* ConnectOptions;
146 
147  QSqlDatabase QtDatabase;
148 
149  friend class vtkQtSQLQuery;
150 
152 
155  virtual bool ParseURL(const char* url);
156 private:
158 
159  // Storing the tables in the database, this array
160  // is accessible through GetTables() method
161  vtkStringArray *myTables;
162 
163  // Storing the currect record list from any one
164  // of the tables in the database, this array is
165  // accessible through GetRecord(const char *table)
166  vtkStringArray *currentRecord;
167 
168  // Used to assign unique identifiers for database instances
169  static int id;
170 
171  vtkQtSQLDatabase(const vtkQtSQLDatabase &); // Not implemented.
172  void operator=(const vtkQtSQLDatabase &); // Not implemented.
173 };
174 
175 #endif // (QT_EDITION & QT_MODULE_SQL)
176 #endif // vtkQtSQLDatabase_h
177 
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
static vtkSQLDatabase * CreateFromURL(const char *URL)
virtual bool IsSupported(int vtkNotUsed(feature))
#define VTK_INT_MAX
Definition: vtkType.h:132
void PrintSelf(ostream &os, vtkIndent indent)
virtual bool Open(const char *password)=0
virtual bool ParseURL(const char *url)=0
virtual bool HasError()=0
a vtkAbstractArray subclass for strings
virtual vtkStdString GetURL()=0
virtual vtkStringArray * GetRecord(const char *table)=0
maintain a connection to an sql database
query class associated with vtkQtSQLDatabase
virtual void Close()=0
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual vtkSQLQuery * GetQueryInstance()=0
virtual bool IsOpen()=0
virtual const char * GetLastErrorText()=0
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:73
static vtkObject * New()
virtual vtkStringArray * GetTables()=0
maintains a connection to an sql database