00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkSQLiteDatabase.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00048 #ifndef __vtkSQLiteDatabase_h 00049 #define __vtkSQLiteDatabase_h 00050 00051 #include "vtkSQLDatabase.h" 00052 00053 class vtkSQLQuery; 00054 class vtkSQLiteQuery; 00055 class vtkStringArray; 00056 struct vtk_sqlite3; 00057 00058 class VTK_IO_EXPORT vtkSQLiteDatabase : public vtkSQLDatabase 00059 { 00060 //BTX 00061 friend class vtkSQLiteQuery; 00062 //ETX 00063 00064 public: 00065 vtkTypeRevisionMacro(vtkSQLiteDatabase, vtkSQLDatabase); 00066 void PrintSelf(ostream& os, vtkIndent indent); 00067 static vtkSQLiteDatabase *New(); 00068 00069 //BTX 00070 enum { 00071 USE_EXISTING, 00072 USE_EXISTING_OR_CREATE, 00073 CREATE_OR_CLEAR, 00074 CREATE 00075 }; 00076 //ETX 00077 00079 00085 bool Open(const char* password); 00086 bool Open(const char* password, int mode); 00088 00090 void Close(); 00091 00093 bool IsOpen(); 00094 00096 vtkSQLQuery* GetQueryInstance(); 00097 00099 vtkStringArray* GetTables(); 00100 00102 vtkStringArray* GetRecord(const char *table); 00103 00105 bool IsSupported(int feature); 00106 00108 bool HasError(); 00109 00111 const char* GetLastErrorText(); 00112 00114 00115 vtkGetStringMacro(DatabaseType); 00117 00119 00120 vtkGetStringMacro(DatabaseFileName); 00121 vtkSetStringMacro(DatabaseFileName); 00123 00125 virtual vtkStdString GetURL(); 00126 00128 00132 virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema, 00133 int tblHandle, 00134 int colHandle ); 00136 00137 protected: 00138 vtkSQLiteDatabase(); 00139 ~vtkSQLiteDatabase(); 00140 00144 virtual bool ParseURL(const char* url); 00145 00146 private: 00147 vtk_sqlite3 *SQLiteInstance; 00148 00149 // We want this to be private, a user of this class 00150 // should not be setting this for any reason 00151 vtkSetStringMacro(DatabaseType); 00152 00153 vtkStringArray *Tables; 00154 00155 char* DatabaseType; 00156 char* DatabaseFileName; 00157 00158 vtkStdString TempURL; 00159 00160 vtkSQLiteDatabase(const vtkSQLiteDatabase &); // Not implemented. 00161 void operator=(const vtkSQLiteDatabase &); // Not implemented. 00162 }; 00163 00164 #endif // __vtkSQLiteDatabase_h 00165