VTK
vtkSQLDatabase.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkSQLDatabase.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
58 #ifndef __vtkSQLDatabase_h
59 #define __vtkSQLDatabase_h
60 
61 #include "vtkObject.h"
62 
63 #include "vtkStdString.h" // Because at least one method returns a vtkStdString
64 
67 class vtkSQLQuery;
68 class vtkStringArray;
69 
70 // This is a list of features that each database may or may not
71 // support. As yet (April 2008) we don't provide access to most of
72 // them.
73 #define VTK_SQL_FEATURE_TRANSACTIONS 1000
74 #define VTK_SQL_FEATURE_QUERY_SIZE 1001
75 #define VTK_SQL_FEATURE_BLOB 1002
76 #define VTK_SQL_FEATURE_UNICODE 1003
77 #define VTK_SQL_FEATURE_PREPARED_QUERIES 1004
78 #define VTK_SQL_FEATURE_NAMED_PLACEHOLDERS 1005
79 #define VTK_SQL_FEATURE_POSITIONAL_PLACEHOLDERS 1006
80 #define VTK_SQL_FEATURE_LAST_INSERT_ID 1007
81 #define VTK_SQL_FEATURE_BATCH_OPERATIONS 1008
82 #define VTK_SQL_FEATURE_TRIGGERS 1009 // supported
83 
84 // Default size for columns types which require a size to be specified
85 // (i.e., VARCHAR), when no size has been specified
86 #define VTK_SQL_DEFAULT_COLUMN_SIZE 32
87 
89 {
90 public:
91  vtkTypeMacro(vtkSQLDatabase, vtkObject);
92  void PrintSelf(ostream& os, vtkIndent indent);
93 
99  virtual bool Open(const char* password) = 0;
100 
102  virtual void Close() = 0;
103 
105  virtual bool IsOpen() = 0;
106 
108  virtual vtkSQLQuery* GetQueryInstance() = 0;
109 
111  virtual bool HasError() = 0;
112 
117  virtual const char* GetLastErrorText() = 0;
118 
120  virtual char* GetDatabaseType() = 0;
121 
123  virtual vtkStringArray* GetTables() = 0;
124 
126  virtual vtkStringArray* GetRecord(const char *table) = 0;
127 
129  virtual bool IsSupported(int vtkNotUsed(feature)) { return false; }
130 
132  virtual vtkStdString GetURL() = 0;
133 
138  virtual vtkStdString GetTablePreamble( bool ) { return vtkStdString(); }
139 
141 
146  virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
147  int tblHandle,
148  int colHandle );
150 
152 
161  virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
162  int tblHandle,
163  int idxHandle,
164  bool& skipped );
166 
168 
176  virtual vtkStdString GetTriggerSpecification( vtkSQLDatabaseSchema* schema,
177  int tblHandle,
178  int trgHandle );
180 
185  static vtkSQLDatabase* CreateFromURL( const char* URL );
186 
188  virtual bool EffectSchema( vtkSQLDatabaseSchema*, bool dropIfExists = false );
189 
190 //BTX
192 
193  typedef vtkSQLDatabase* (*CreateFunction)(const char* URL);
194 //ETX
196 
198 
202  static void RegisterCreateFromURLCallback(CreateFunction callback);
203  static void UnRegisterCreateFromURLCallback(CreateFunction callback);
204  static void UnRegisterAllCreateFromURLCallbacks();
206 
214  static vtkInformationObjectBaseKey* DATABASE();
215 
216 //BTX
217 protected:
218  vtkSQLDatabase();
219  ~vtkSQLDatabase();
220 
225  virtual bool ParseURL( const char* url ) = 0;
226 
227 private:
228  vtkSQLDatabase(const vtkSQLDatabase &); // Not implemented.
229  void operator=(const vtkSQLDatabase &); // Not implemented.
230 
232 
233  class vtkCallbackVector;
234  static vtkCallbackVector* Callbacks;
235 //ETX
236 };
238 
239 #endif // __vtkSQLDatabase_h