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);
94  static vtkODBCDatabase *New();
95 
101  bool Open(const char* password);
102 
106  void Close();
107 
111  bool IsOpen();
112 
117 
121  const char* GetLastErrorText();
122 
127 
131  vtkStringArray* GetRecord(const char *table);
132 
136  bool IsSupported(int feature);
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();
156 
158 
161  vtkGetStringMacro(DatabaseType);
163 
165 
174  int tblHandle,
175  int colHandle );
176 
182  int tblHandle,
183  int idxHandle,
184  bool& skipped );
185 
190  bool CreateDatabase( const char* dbName, bool dropExisting );
191 
196  bool DropDatabase( const char* dbName );
197 
203  bool ParseURL(const char *url);
204 
205 protected:
206  vtkODBCDatabase();
207  ~vtkODBCDatabase();
208 
209  vtkSetStringMacro(LastErrorText);
210 
211 private:
212  vtkStringArray *Tables;
213  vtkStringArray *Record;
214 
215  char *LastErrorText;
216 
217  char *HostName;
218  char *UserName;
219  char *Password;
220  char *DataSourceName;
221  char *DatabaseName;
222  int ServerPort;
223 
224  vtkODBCInternals *Internals;
225 
226  // We want this to be private, a user of this class
227  // should not be setting this for any reason
228  vtkSetStringMacro(DatabaseType);
229 
230  char *DatabaseType;
231 
232  vtkODBCDatabase(const vtkODBCDatabase &) VTK_DELETE_FUNCTION;
233  void operator=(const vtkODBCDatabase &) VTK_DELETE_FUNCTION;
234 };
235 
236 #endif // vtkODBCDatabase_h
237 
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
virtual VTK_NEWINSTANCE vtkSQLQuery * GetQueryInstance()=0
Return an empty query on this database.
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.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
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.
maintain a connection to an sql database
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 bool IsOpen()=0
Return whether the database has an open connection.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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