VTK  9.3.0
vtkPostgreSQLDatabasePrivate.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4 
20 #ifndef vtkPostgreSQLDatabasePrivate_h
21 #define vtkPostgreSQLDatabasePrivate_h
22 
23 #include "vtkTimeStamp.h"
24 #include "vtkType.h"
25 
26 #include <libpq-fe.h>
27 #include <map>
28 
29 VTK_ABI_NAMESPACE_BEGIN
31 {
32 public:
34 
39  {
40  if (this->Connection)
41  {
42  PQfinish(this->Connection);
43  }
44  }
45 
46  // Given a Postgres column type OID, return a VTK array type (see vtkType.h).
47  int GetVTKTypeFromOID(Oid pgtype)
48  {
49  std::map<Oid, int>::const_iterator it = this->DataTypeMap.find(pgtype);
50  if (it == this->DataTypeMap.end())
51  {
52  return VTK_STRING;
53  }
54  return it->second;
55  }
56 
57  // This is the actual database connection. It will be nullptr if no
58  // connection is open.
59  PGconn* Connection;
60 
61  // Map Postgres column types to VTK types.
62  std::map<Oid, int> DataTypeMap;
63 };
64 
65 VTK_ABI_NAMESPACE_END
66 #endif // vtkPostgreSQLDatabasePrivate_h
67 // VTK-HeaderTest-Exclude: vtkPostgreSQLDatabasePrivate.h
internal details of a connection to a PostgreSQL database
virtual ~vtkPostgreSQLDatabasePrivate()
Destroy the database connection.
#define VTK_STRING
Definition: vtkType.h:48