VTK
vtkPostgreSQLDatabasePrivate.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPostgreSQLDatabasePrivate.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 -------------------------------------------------------------------------*/
20 
36 #ifndef vtkPostgreSQLDatabasePrivate_h
37 #define vtkPostgreSQLDatabasePrivate_h
38 
39 #include "vtkStdString.h"
40 #include "vtkType.h"
41 #include "vtkTimeStamp.h"
42 
43 #include <libpq-fe.h>
44 #include <map>
45 
47 {
48  public:
50  {
51  this->Connection = NULL;
52  }
53 
58  {
59  if (this->Connection)
60  {
61  PQfinish(this->Connection);
62  }
63  }
64 
65  // Given a Postgres column type OID, return a VTK array type (see vtkType.h).
66  int GetVTKTypeFromOID( Oid pgtype )
67  {
68  std::map<Oid,int>::const_iterator it = this->DataTypeMap.find( pgtype );
69  if ( it == this->DataTypeMap.end() )
70  {
71  return VTK_STRING;
72  }
73  return it->second;
74  }
75 
76 
77 
78  // This is the actual database connection. It will be NULL if no
79  // connection is open.
80  PGconn *Connection;
81 
82  // Map Postgres column types to VTK types.
83  std::map<Oid,int> DataTypeMap;
84 };
85 
86 #endif // vtkPostgreSQLDatabasePrivate_h
87 // VTK-HeaderTest-Exclude: vtkPostgreSQLDatabasePrivate.h
internal details of a connection to a PostgreSQL database
#define VTK_STRING
Definition: vtkType.h:64
virtual ~vtkPostgreSQLDatabasePrivate()
Destroy the database connection.