VTK
vtkMySQLDatabase.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMySQLDatabase.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 -------------------------------------------------------------------------*/
38 #ifndef vtkMySQLDatabase_h
39 #define vtkMySQLDatabase_h
40 
41 #include "vtkIOMySQLModule.h" // For export macro
42 #include "vtkSQLDatabase.h"
43 
44 class vtkSQLQuery;
45 class vtkMySQLQuery;
46 class vtkStringArray;
48 
49 class VTKIOMYSQL_EXPORT vtkMySQLDatabase : public vtkSQLDatabase
50 {
51 //BTX
52  friend class vtkMySQLQuery;
53 //ETX
54 
55 public:
57  void PrintSelf(ostream& os, vtkIndent indent);
58  static vtkMySQLDatabase *New();
59 
63  bool Open( const char* password = 0 );
64 
66  void Close();
67 
69  bool IsOpen();
70 
73 
76 
78  vtkStringArray* GetRecord(const char *table);
79 
81  bool IsSupported(int feature);
82 
84  bool HasError();
85 
87  const char* GetLastErrorText();
88 
90 
91  vtkGetStringMacro(DatabaseType);
93 
95 
96  vtkSetStringMacro(HostName);
97  vtkGetStringMacro(HostName);
99 
101 
102  vtkSetStringMacro(User);
103  vtkGetStringMacro(User);
105 
107 
108  vtkSetStringMacro(Password);
110 
112 
113  vtkSetStringMacro(DatabaseName);
114  vtkGetStringMacro(DatabaseName);
116 
118 
120  vtkSetMacro(Reconnect,int);
121  vtkGetMacro(Reconnect,int);
122  vtkBooleanMacro(Reconnect,int);
124 
126 
127  vtkSetClampMacro(ServerPort, int, 0, VTK_INT_MAX);
128  vtkGetMacro(ServerPort, int);
130 
132  virtual vtkStdString GetURL();
133 
137  virtual vtkStdString GetTablePreamble( bool b ) { return b ? vtkStdString() :"IF NOT EXISTS "; }
138 
140 
148  int tblHandle,
149  int colHandle );
151 
153 
160  int tblHandle,
161  int idxHandle,
162  bool& skipped );
164 
168  bool CreateDatabase( const char* dbName, bool dropExisting );
169 
172  bool DropDatabase( const char* dbName );
173 
177  virtual bool ParseURL(const char* url);
178 
179 protected:
181  ~vtkMySQLDatabase();
182 
183 private:
184  // We want this to be private, a user of this class
185  // should not be setting this for any reason
186  vtkSetStringMacro(DatabaseType);
187 
188  vtkStringArray *Tables;
189  vtkStringArray *Record;
190 
191  char* DatabaseType;
192  char* HostName;
193  char* User;
194  char* Password;
195  char* DatabaseName;
196  int ServerPort;
197  int Reconnect;
198 
199 //BTX
200  vtkMySQLDatabasePrivate* const Private;
201 //ETX
202 
203  vtkMySQLDatabase(const vtkMySQLDatabase &); // Not implemented.
204  void operator=(const vtkMySQLDatabase &); // Not implemented.
205 };
206 
207 #endif // vtkMySQLDatabase_h
208 
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
virtual vtkStdString GetColumnSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int colHandle)
virtual vtkStdString GetTablePreamble(bool b)
virtual bool IsSupported(int vtkNotUsed(feature))
#define VTK_INT_MAX
Definition: vtkType.h:132
void PrintSelf(ostream &os, vtkIndent indent)
virtual bool Open(const char *password)=0
virtual bool ParseURL(const char *url)=0
virtual bool HasError()=0
a vtkAbstractArray subclass for strings
virtual vtkStdString GetURL()=0
represent an SQL database schema
virtual vtkStringArray * GetRecord(const char *table)=0
maintain a connection to a MySQL database
maintain a connection to an sql database
friend class vtkMySQLDatabase
Definition: vtkMySQLQuery.h:49
virtual void Close()=0
virtual vtkStdString GetIndexSpecification(vtkSQLDatabaseSchema *schema, int tblHandle, int idxHandle, bool &skipped)
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual vtkSQLQuery * GetQueryInstance()=0
virtual bool IsOpen()=0
virtual const char * GetLastErrorText()=0
executes an sql query and retrieves results
Definition: vtkSQLQuery.h:73
vtkSQLQuery implementation for MySQL databases
Definition: vtkMySQLQuery.h:46
static vtkObject * New()
virtual vtkStringArray * GetTables()=0