00001 /* -*- Mode: C++; -*- */ 00002 /*========================================================================= 00003 00004 Program: Visualization Toolkit 00005 Module: vtkPostgreSQLDatabasePrivate.h 00006 00007 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00016 /*------------------------------------------------------------------------- 00017 Copyright 2008 Sandia Corporation. 00018 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00019 the U.S. Government retains certain rights in this software. 00020 -------------------------------------------------------------------------*/ 00021 00036 #ifndef __vtkPostgreSQLDatabasePrivate_h 00037 #define __vtkPostgreSQLDatabasePrivate_h 00038 00039 #include "vtkStdString.h" 00040 #include "vtkType.h" 00041 #include "vtkTimeStamp.h" 00042 00043 #include <libpq-fe.h> 00044 #include <vtksys/stl/map> 00045 00046 class vtkPostgreSQLDatabasePrivate 00047 { 00048 public: 00049 vtkPostgreSQLDatabasePrivate() 00050 { 00051 this->Connection = NULL; 00052 } 00053 00055 00057 virtual ~vtkPostgreSQLDatabasePrivate() 00058 { 00059 if (this->Connection) 00060 { 00061 PQfinish(this->Connection); 00062 } 00063 } 00065 00066 // Given a Postgres column type OID, return a VTK array type (see vtkType.h). 00067 int GetVTKTypeFromOID( Oid pgtype ) 00068 { 00069 vtksys_stl::map<Oid,int>::const_iterator it = this->DataTypeMap.find( pgtype ); 00070 if ( it == this->DataTypeMap.end() ) 00071 { 00072 return VTK_STRING; 00073 } 00074 return it->second; 00075 } 00076 00077 00078 00079 // This is the actual database connection. It will be NULL if no 00080 // connection is open. 00081 PGconn *Connection; 00082 00083 // Map Postgres column types to VTK types. 00084 vtksys_stl::map<Oid,int> DataTypeMap; 00085 }; 00086 00087 #endif // __vtkPostgreSQLDatabasePrivate_h