VTK
vtkODBCDatabase.h
Go to the documentation of this file.
1 /* -*- Mode: C++; -*- */
2 
3 /*=========================================================================
4 
5  Program: Visualization Toolkit
6  Module: vtkODBCDatabase.h
7 
8  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
9  All rights reserved.
10  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notice for more information.
15 
16 =========================================================================*/
17 /*-------------------------------------------------------------------------
18  Copyright 2008 Sandia Corporation.
19  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
20  the U.S. Government retains certain rights in this software.
21 -------------------------------------------------------------------------*/
22 
75 #ifndef vtkODBCDatabase_h
76 #define vtkODBCDatabase_h
77 
78 #include "vtkIOODBCModule.h" // For export macro
79 #include "vtkSQLDatabase.h"
80 
81 class vtkSQLQuery;
82 class vtkODBCQuery;
83 class vtkStringArray;
84 class vtkODBCInternals;
85 
86 class VTKIOODBC_EXPORT vtkODBCDatabase : public vtkSQLDatabase
87 {
88 
89  friend class vtkODBCQuery;
90 
91 public:
93  void PrintSelf(ostream& os, vtkIndent indent) override;
94  static vtkODBCDatabase *New();
95 
101  bool Open(const char* password) override;
102 
106  void Close() override;
107 
111  bool IsOpen() override;
112 
116  vtkSQLQuery* GetQueryInstance() override;
117 
121  const char* GetLastErrorText() override;
122 
126  vtkStringArray* GetTables() override;
127 
131  vtkStringArray* GetRecord(const char *table) override;
132 
136  bool IsSupported(int feature) override;
137 
139 
144  vtkSetStringMacro(DataSourceName);
145  vtkGetStringMacro(DataSourceName);
147 
148  vtkSetMacro(ServerPort, int);
149  vtkSetStringMacro(HostName);
150  vtkSetStringMacro(UserName);
151  vtkSetStringMacro(DatabaseName);
152  vtkGetStringMacro(DatabaseName);
153  vtkSetStringMacro(Password);
154 
155  bool HasError() override;
156 
158 
161  const char* GetDatabaseType() override
162  {
163  return this->DatabaseType;
164  }
166 
167  vtkStdString GetURL() override;
168 
177  int tblHandle,
178  int colHandle ) override;
179 
185  int tblHandle,
186  int idxHandle,
187  bool& skipped ) override;
188 
193  bool CreateDatabase( const char* dbName, bool dropExisting );
194 
199  bool DropDatabase( const char* dbName );
200 
206  bool ParseURL(const char *url) override;
207 
208 protected:
209  vtkODBCDatabase();
210  ~vtkODBCDatabase();
211 
212  vtkSetStringMacro(LastErrorText);
213 
214 private:
215  vtkStringArray *Tables;
216  vtkStringArray *Record;
217 
218  char *LastErrorText;
219 
220  char *HostName;
221  char *UserName;
222  char *Password;
223  char *DataSourceName;
224  char *DatabaseName;
225  int ServerPort;
226 
227  vtkODBCInternals *Internals;
228 
229  // We want this to be private, a user of this class
230  // should not be setting this for any reason
231  vtkSetStringMacro(DatabaseType);
232 
233  char *DatabaseType;
234 
235  vtkODBCDatabase(const vtkODBCDatabase &) = delete;
236  void operator=(const vtkODBCDatabase &) = delete;
237 };
238 
239 #endif // vtkODBCDatabase_h
240 
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
virtual vtkStdString GetColumnSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int colHandle)
Return the SQL string with the syntax to create a column inside a "CREATE TABLE" SQL statement...
virtual bool IsSupported(int vtkNotUsed(feature))
Return whether a feature is supported by the database.
virtual bool Open(const char *password)=0
Open a new connection to the database.
virtual bool ParseURL(const char *url)=0
Subclasses should override this method to determine connection parameters given the URL...
virtual bool HasError()=0
Did the last operation generate an error.
a vtkAbstractArray subclass for strings
virtual vtkStdString GetURL()=0
Get the URL of the database.
represent an SQL database schema
virtual vtkStringArray * GetRecord(const char *table)=0
Get the list of fields for a particular table.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
maintain a connection to an sql database
const char * GetDatabaseType() override
String representing database type (e.g.
virtual void Close()=0
Close the connection to the database.
Simple class to hide ODBC structures.
virtual vtkStdString GetIndexSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int idxHandle, bool &skipped)
Return the SQL string with the syntax to create an index inside a "CREATE TABLE" SQL statement...
a simple class to control print indentation
Definition: vtkIndent.h:39
friend class vtkODBCDatabase
Definition: vtkODBCQuery.h:51
maintain an ODBC connection to a SQL database
virtual vtkSQLQuery * GetQueryInstance()=0
Return an empty query on this database.
virtual bool IsOpen()=0
Return whether the database has an open connection.
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...
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:74
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual vtkStringArray * GetTables()=0
Get the list of tables from the database.
vtkSQLQuery implementation for ODBC connections to databases
Definition: vtkODBCQuery.h:48