VTK
dox/IO/vtkODBCDatabase.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; -*- */
00002 
00003 /*=========================================================================
00004 
00005   Program:   Visualization Toolkit
00006   Module:    vtkODBCDatabase.h
00007 
00008   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00009   All rights reserved.
00010   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notice for more information.
00015 
00016 =========================================================================*/
00017 /*-------------------------------------------------------------------------
00018   Copyright 2008 Sandia Corporation.
00019   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00020   the U.S. Government retains certain rights in this software.
00021 -------------------------------------------------------------------------*/
00022 
00074 #ifndef __vtkODBCDatabase_h
00075 #define __vtkODBCDatabase_h
00076 
00077 #include "vtkSQLDatabase.h"
00078 
00079 class vtkSQLQuery;
00080 class vtkODBCQuery;
00081 class vtkStringArray;
00082 class vtkODBCInternals;
00083 
00084 class VTK_IO_EXPORT vtkODBCDatabase : public vtkSQLDatabase
00085 {
00086 //BTX
00087   friend class vtkODBCQuery;
00088 //ETX
00089 
00090 public:
00091   vtkTypeMacro(vtkODBCDatabase, vtkSQLDatabase);
00092   void PrintSelf(ostream& os, vtkIndent indent);
00093   static vtkODBCDatabase *New();
00094 
00098   bool Open(const char* password);
00099 
00101   void Close();
00102 
00104   bool IsOpen();
00105 
00107   vtkSQLQuery* GetQueryInstance();
00108 
00110   const char* GetLastErrorText();
00111 
00113   vtkStringArray* GetTables();
00114 
00116   vtkStringArray* GetRecord(const char *table);
00117 
00119   bool IsSupported(int feature);
00120 
00122 
00125   vtkSetStringMacro(DataSourceName);
00126   vtkGetStringMacro(DataSourceName);
00128 
00129   vtkSetMacro(ServerPort, int);
00130   vtkSetStringMacro(HostName);
00131   vtkSetStringMacro(UserName);
00132   vtkSetStringMacro(DatabaseName);
00133   vtkGetStringMacro(DatabaseName);
00134   vtkSetStringMacro(Password);
00135 
00136   bool HasError();
00137 
00139 
00140   vtkGetStringMacro(DatabaseType);
00142 
00143   vtkStdString GetURL();
00144 
00146 
00150   virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
00151                                                int tblHandle,
00152                                                int colHandle );
00154 
00156 
00158   virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
00159                                               int tblHandle,
00160                                               int idxHandle,
00161                                               bool& skipped );
00163 
00167   bool CreateDatabase( const char* dbName, bool dropExisting );
00168 
00171   bool DropDatabase( const char* dbName );
00172 
00176   bool ParseURL(const char *url);
00177 
00178 protected:
00179   vtkODBCDatabase();
00180   ~vtkODBCDatabase();
00181 
00182   vtkSetStringMacro(LastErrorText);
00183 
00184 private:
00185   vtkStringArray *Tables;
00186   vtkStringArray *Record;
00187 
00188   char *LastErrorText;
00189 
00190   char *HostName;
00191   char *UserName;
00192   char *Password;
00193   char *DataSourceName;
00194   char *DatabaseName;
00195   int ServerPort;
00196 
00197   vtkODBCInternals *Internals;
00198 
00199   // We want this to be private, a user of this class
00200   // should not be setting this for any reason
00201   vtkSetStringMacro(DatabaseType);
00202 
00203   char *DatabaseType;
00204 
00205   vtkODBCDatabase(const vtkODBCDatabase &); // Not implemented.
00206   void operator=(const vtkODBCDatabase &); // Not implemented.
00207 };
00208 
00209 #endif // __vtkODBCDatabase_h
00210