VTK
vtkPostgreSQLDatabasePrivate.h
Go to the documentation of this file.
1 /* -*- Mode: C++; -*- */
2 /*=========================================================================
3 
4  Program: Visualization Toolkit
5  Module: vtkPostgreSQLDatabasePrivate.h
6 
7  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8  All rights reserved.
9  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notice for more information.
14 
15 =========================================================================*/
16 /*-------------------------------------------------------------------------
17  Copyright 2008 Sandia Corporation.
18  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
19  the U.S. Government retains certain rights in this software.
20 -------------------------------------------------------------------------*/
21 
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 <vtksys/stl/map>
45 
47 {
48  public:
50  {
51  this->Connection = NULL;
52  }
53 
55 
58  {
59  if (this->Connection)
60  {
61  PQfinish(this->Connection);
62  }
63  }
65 
66  // Given a Postgres column type OID, return a VTK array type (see vtkType.h).
67  int GetVTKTypeFromOID( Oid pgtype )
68  {
69  vtksys_stl::map<Oid,int>::const_iterator it = this->DataTypeMap.find( pgtype );
70  if ( it == this->DataTypeMap.end() )
71  {
72  return VTK_STRING;
73  }
74  return it->second;
75  }
76 
77 
78 
79  // This is the actual database connection. It will be NULL if no
80  // connection is open.
81  PGconn *Connection;
82 
83  // Map Postgres column types to VTK types.
84  vtksys_stl::map<Oid,int> DataTypeMap;
85 };
86 
87 #endif // vtkPostgreSQLDatabasePrivate_h
88 // VTK-HeaderTest-Exclude: vtkPostgreSQLDatabasePrivate.h
internal details of a connection to a PostgreSQL database
#define VTK_STRING
Definition: vtkType.h:41
vtksys_stl::map< Oid, int > DataTypeMap