VTK
dox/IO/vtkSQLiteDatabase.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkSQLiteDatabase.h
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 -------------------------------------------------------------------------*/
00051 #ifndef __vtkSQLiteDatabase_h
00052 #define __vtkSQLiteDatabase_h
00053 
00054 #include "vtkSQLDatabase.h"
00055 
00056 class vtkSQLQuery;
00057 class vtkSQLiteQuery;
00058 class vtkStringArray;
00059 struct vtk_sqlite3;
00060 
00061 class VTK_IO_EXPORT vtkSQLiteDatabase : public vtkSQLDatabase
00062 {
00063   //BTX
00064   friend class vtkSQLiteQuery;
00065   //ETX
00066 
00067 public:
00068   vtkTypeMacro(vtkSQLiteDatabase, vtkSQLDatabase);
00069   void PrintSelf(ostream& os, vtkIndent indent);
00070   static vtkSQLiteDatabase *New();
00071 
00072   //BTX
00073   enum {
00074     USE_EXISTING,
00075     USE_EXISTING_OR_CREATE,
00076     CREATE_OR_CLEAR,
00077     CREATE
00078   };
00079   //ETX
00080 
00082 
00088   bool Open(const char* password);
00089   bool Open(const char* password, int mode);
00091 
00093   void Close();
00094   
00096   bool IsOpen();
00097 
00099   vtkSQLQuery* GetQueryInstance();
00100   
00102   vtkStringArray* GetTables();
00103     
00105   vtkStringArray* GetRecord(const char *table);
00106 
00108   bool IsSupported(int feature);
00109   
00111   bool HasError();
00112   
00114   const char* GetLastErrorText();
00115   
00117 
00118   vtkGetStringMacro(DatabaseType);
00120 
00122 
00123   vtkGetStringMacro(DatabaseFileName);
00124   vtkSetStringMacro(DatabaseFileName);
00126   
00128   virtual vtkStdString GetURL();
00129 
00131 
00135   virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
00136                                                int tblHandle,
00137                                                int colHandle );
00139  
00140 protected:
00141   vtkSQLiteDatabase();
00142   ~vtkSQLiteDatabase();
00143 
00147   virtual bool ParseURL(const char* url);
00148 
00149 private:
00150   vtk_sqlite3 *SQLiteInstance;
00151   
00152   // We want this to be private, a user of this class
00153   // should not be setting this for any reason
00154   vtkSetStringMacro(DatabaseType);
00155 
00156   vtkStringArray *Tables;
00157   
00158   char* DatabaseType;
00159   char* DatabaseFileName;
00160 
00161   vtkStdString TempURL;
00162   
00163   vtkSQLiteDatabase(const vtkSQLiteDatabase &); // Not implemented.
00164   void operator=(const vtkSQLiteDatabase &); // Not implemented.
00165 };
00166 
00167 #endif // __vtkSQLiteDatabase_h
00168