VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/IO/SQL/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 "vtkIOSQLModule.h" // For export macro
00062 #include "vtkObject.h"
00063 
00064 #include "vtkStdString.h" // Because at least one method returns a vtkStdString
00065 
00066 class vtkInformationObjectBaseKey;
00067 class vtkSQLDatabaseSchema;
00068 class vtkSQLQuery;
00069 class vtkStringArray;
00070 
00071 // This is a list of features that each database may or may not
00072 // support.  As yet (April 2008) we don't provide access to most of
00073 // them.
00074 #define VTK_SQL_FEATURE_TRANSACTIONS            1000
00075 #define VTK_SQL_FEATURE_QUERY_SIZE              1001
00076 #define VTK_SQL_FEATURE_BLOB                    1002
00077 #define VTK_SQL_FEATURE_UNICODE                 1003
00078 #define VTK_SQL_FEATURE_PREPARED_QUERIES        1004
00079 #define VTK_SQL_FEATURE_NAMED_PLACEHOLDERS      1005
00080 #define VTK_SQL_FEATURE_POSITIONAL_PLACEHOLDERS 1006
00081 #define VTK_SQL_FEATURE_LAST_INSERT_ID          1007
00082 #define VTK_SQL_FEATURE_BATCH_OPERATIONS        1008
00083 #define VTK_SQL_FEATURE_TRIGGERS                1009 // supported
00084 
00085 // Default size for columns types which require a size to be specified
00086 // (i.e., VARCHAR), when no size has been specified
00087 #define VTK_SQL_DEFAULT_COLUMN_SIZE 32
00088 
00089 class VTKIOSQL_EXPORT vtkSQLDatabase : public vtkObject
00090 {
00091 public:
00092   vtkTypeMacro(vtkSQLDatabase, vtkObject);
00093   void PrintSelf(ostream& os, vtkIndent indent);
00094 
00100   virtual bool Open(const char* password) = 0;
00101 
00103   virtual void Close() = 0;
00104 
00106   virtual bool IsOpen() = 0;
00107 
00109   virtual vtkSQLQuery* GetQueryInstance() = 0;
00110 
00112   virtual bool HasError() = 0;
00113 
00118   virtual const char* GetLastErrorText() = 0;
00119 
00121   virtual char* GetDatabaseType() = 0;
00122 
00124   virtual vtkStringArray* GetTables() = 0;
00125 
00127   virtual vtkStringArray* GetRecord(const char *table) = 0;
00128 
00130   virtual bool IsSupported(int vtkNotUsed(feature)) { return false; }
00131 
00133   virtual vtkStdString GetURL() = 0;
00134 
00139   virtual vtkStdString GetTablePreamble( bool ) { return vtkStdString(); }
00140 
00142 
00147   virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
00148                                                int tblHandle,
00149                                                int colHandle );
00151 
00153 
00162   virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
00163                                               int tblHandle,
00164                                               int idxHandle,
00165                                               bool& skipped );
00167 
00169 
00177   virtual vtkStdString GetTriggerSpecification( vtkSQLDatabaseSchema* schema,
00178                                                 int tblHandle,
00179                                                 int trgHandle );
00181 
00186   static vtkSQLDatabase* CreateFromURL( const char* URL );
00187 
00189   virtual bool EffectSchema( vtkSQLDatabaseSchema*, bool dropIfExists = false );
00190 
00191 //BTX
00193 
00194   typedef vtkSQLDatabase* (*CreateFunction)(const char* URL);
00195 //ETX
00197 
00199 
00203   static void RegisterCreateFromURLCallback(CreateFunction callback);
00204   static void UnRegisterCreateFromURLCallback(CreateFunction callback);
00205   static void UnRegisterAllCreateFromURLCallbacks();
00207 
00215   static vtkInformationObjectBaseKey* DATABASE();
00216 
00217 //BTX
00218 protected:
00219   vtkSQLDatabase();
00220   ~vtkSQLDatabase();
00221 
00226   virtual bool ParseURL( const char* url ) = 0;
00227 
00228 private:
00229   vtkSQLDatabase(const vtkSQLDatabase &); // Not implemented.
00230   void operator=(const vtkSQLDatabase &); // Not implemented.
00231 
00233 
00234   class vtkCallbackVector;
00235   static vtkCallbackVector* Callbacks;
00236 //ETX
00237 };
00239 
00240 #endif // vtkSQLDatabase_h