VTK
dox/IO/vtkSQLDatabase.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Visualization Toolkit
00004 Module:    vtkSQLDatabase.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 -------------------------------------------------------------------------*/
00058 #ifndef __vtkSQLDatabase_h
00059 #define __vtkSQLDatabase_h
00060 
00061 #include "vtkObject.h"
00062 
00063 #include "vtkStdString.h" // Because at least one method returns a vtkStdString
00064 
00065 class vtkInformationObjectBaseKey;
00066 class vtkSQLDatabaseSchema;
00067 class vtkSQLQuery;
00068 class vtkStringArray;
00069 
00070 // This is a list of features that each database may or may not
00071 // support.  As yet (April 2008) we don't provide access to most of
00072 // them.
00073 #define VTK_SQL_FEATURE_TRANSACTIONS            1000
00074 #define VTK_SQL_FEATURE_QUERY_SIZE              1001
00075 #define VTK_SQL_FEATURE_BLOB                    1002
00076 #define VTK_SQL_FEATURE_UNICODE                 1003
00077 #define VTK_SQL_FEATURE_PREPARED_QUERIES        1004
00078 #define VTK_SQL_FEATURE_NAMED_PLACEHOLDERS      1005
00079 #define VTK_SQL_FEATURE_POSITIONAL_PLACEHOLDERS 1006
00080 #define VTK_SQL_FEATURE_LAST_INSERT_ID          1007
00081 #define VTK_SQL_FEATURE_BATCH_OPERATIONS        1008
00082 #define VTK_SQL_FEATURE_TRIGGERS                1009 // supported
00083 
00084 // Default size for columns types which require a size to be specified
00085 // (i.e., VARCHAR), when no size has been specified
00086 #define VTK_SQL_DEFAULT_COLUMN_SIZE 32
00087 
00088 class VTK_IO_EXPORT vtkSQLDatabase : public vtkObject
00089 {
00090 public:
00091   vtkTypeMacro(vtkSQLDatabase, vtkObject);
00092   void PrintSelf(ostream& os, vtkIndent indent);
00093 
00099   virtual bool Open(const char* password) = 0;
00100 
00102   virtual void Close() = 0;
00103 
00105   virtual bool IsOpen() = 0;
00106 
00108   virtual vtkSQLQuery* GetQueryInstance() = 0;
00109 
00111   virtual bool HasError() = 0;
00112 
00117   virtual const char* GetLastErrorText() = 0;
00118 
00120   virtual char* GetDatabaseType() = 0;
00121 
00123   virtual vtkStringArray* GetTables() = 0;
00124 
00126   virtual vtkStringArray* GetRecord(const char *table) = 0;
00127 
00129   virtual bool IsSupported(int vtkNotUsed(feature)) { return false; }
00130 
00132   virtual vtkStdString GetURL() = 0;
00133 
00138   virtual vtkStdString GetTablePreamble( bool ) { return vtkStdString(); }
00139 
00141 
00146   virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
00147                                                int tblHandle,
00148                                                int colHandle );
00150 
00152 
00161   virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
00162                                               int tblHandle,
00163                                               int idxHandle,
00164                                               bool& skipped );
00166 
00168 
00176   virtual vtkStdString GetTriggerSpecification( vtkSQLDatabaseSchema* schema,
00177                                                 int tblHandle,
00178                                                 int trgHandle );
00180 
00185   static vtkSQLDatabase* CreateFromURL( const char* URL );
00186 
00188   virtual bool EffectSchema( vtkSQLDatabaseSchema*, bool dropIfExists = false );
00189 
00190 //BTX
00192 
00193   typedef vtkSQLDatabase* (*CreateFunction)(const char* URL);
00194 //ETX
00196 
00198 
00202   static void RegisterCreateFromURLCallback(CreateFunction callback);
00203   static void UnRegisterCreateFromURLCallback(CreateFunction callback);
00204   static void UnRegisterAllCreateFromURLCallbacks();
00206 
00214   static vtkInformationObjectBaseKey* DATABASE();
00215 
00216 //BTX
00217 protected:
00218   vtkSQLDatabase();
00219   ~vtkSQLDatabase();
00220 
00225   virtual bool ParseURL( const char* url ) = 0;
00226 
00227 private:
00228   vtkSQLDatabase(const vtkSQLDatabase &); // Not implemented.
00229   void operator=(const vtkSQLDatabase &); // Not implemented.
00230 
00232 
00233   class vtkCallbackVector;
00234   static vtkCallbackVector* Callbacks;
00235 //ETX
00236 };
00238 
00239 #endif // __vtkSQLDatabase_h