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 "vtkIOSQLModule.h" // For export macro
62 #include "vtkObject.h"
63 
64 #include "vtkStdString.h" // Because at least one method returns a vtkStdString
65 
68 class vtkSQLQuery;
69 class vtkStringArray;
70 
71 // This is a list of features that each database may or may not
72 // support. As yet (April 2008) we don't provide access to most of
73 // them.
74 #define VTK_SQL_FEATURE_TRANSACTIONS 1000
75 #define VTK_SQL_FEATURE_QUERY_SIZE 1001
76 #define VTK_SQL_FEATURE_BLOB 1002
77 #define VTK_SQL_FEATURE_UNICODE 1003
78 #define VTK_SQL_FEATURE_PREPARED_QUERIES 1004
79 #define VTK_SQL_FEATURE_NAMED_PLACEHOLDERS 1005
80 #define VTK_SQL_FEATURE_POSITIONAL_PLACEHOLDERS 1006
81 #define VTK_SQL_FEATURE_LAST_INSERT_ID 1007
82 #define VTK_SQL_FEATURE_BATCH_OPERATIONS 1008
83 #define VTK_SQL_FEATURE_TRIGGERS 1009 // supported
84 
85 // Default size for columns types which require a size to be specified
86 // (i.e., VARCHAR), when no size has been specified
87 #define VTK_SQL_DEFAULT_COLUMN_SIZE 32
88 
90 {
91 public:
92  vtkTypeMacro(vtkSQLDatabase, vtkObject);
93  void PrintSelf(ostream& os, vtkIndent indent);
94 
100  virtual bool Open(const char* password) = 0;
101 
103  virtual void Close() = 0;
104 
106  virtual bool IsOpen() = 0;
107 
109  virtual vtkSQLQuery* GetQueryInstance() = 0;
110 
112  virtual bool HasError() = 0;
113 
118  virtual const char* GetLastErrorText() = 0;
119 
121  virtual char* GetDatabaseType() = 0;
122 
124  virtual vtkStringArray* GetTables() = 0;
125 
127  virtual vtkStringArray* GetRecord(const char *table) = 0;
128 
130  virtual bool IsSupported(int vtkNotUsed(feature)) { return false; }
131 
133  virtual vtkStdString GetURL() = 0;
134 
139  virtual vtkStdString GetTablePreamble( bool ) { return vtkStdString(); }
140 
142 
147  virtual vtkStdString GetColumnSpecification( vtkSQLDatabaseSchema* schema,
148  int tblHandle,
149  int colHandle );
151 
153 
162  virtual vtkStdString GetIndexSpecification( vtkSQLDatabaseSchema* schema,
163  int tblHandle,
164  int idxHandle,
165  bool& skipped );
167 
169 
177  virtual vtkStdString GetTriggerSpecification( vtkSQLDatabaseSchema* schema,
178  int tblHandle,
179  int trgHandle );
181 
186  static vtkSQLDatabase* CreateFromURL( const char* URL );
187 
189  virtual bool EffectSchema( vtkSQLDatabaseSchema*, bool dropIfExists = false );
190 
191 //BTX
193 
194  typedef vtkSQLDatabase* (*CreateFunction)(const char* URL);
195 //ETX
197 
199 
203  static void RegisterCreateFromURLCallback(CreateFunction callback);
204  static void UnRegisterCreateFromURLCallback(CreateFunction callback);
205  static void UnRegisterAllCreateFromURLCallbacks();
207 
215  static vtkInformationObjectBaseKey* DATABASE();
216 
217 //BTX
218 protected:
219  vtkSQLDatabase();
220  ~vtkSQLDatabase();
221 
226  virtual bool ParseURL( const char* url ) = 0;
227 
228 private:
229  vtkSQLDatabase(const vtkSQLDatabase &); // Not implemented.
230  void operator=(const vtkSQLDatabase &); // Not implemented.
231 
233 
234  class vtkCallbackVector;
235  static vtkCallbackVector* Callbacks;
236 //ETX
237 };
239 
240 #endif // vtkSQLDatabase_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
abstract base class for most VTK objects
Definition: vtkObject.h:61
virtual bool IsSupported(int vtkNotUsed(feature))
a vtkAbstractArray subclass for strings
represent an SQL database schema
virtual vtkStdString GetTablePreamble(bool)
maintain a connection to an sql database
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
Key for vtkObjectBase values.
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:73
#define VTKIOSQL_EXPORT