vtkPostgreSQLDatabase Class Reference

#include <vtkPostgreSQLDatabase.h>

Inheritance diagram for vtkPostgreSQLDatabase:

Inheritance graph
[legend]
Collaboration diagram for vtkPostgreSQLDatabase:

Collaboration graph
[legend]

List of all members.


Detailed Description

maintain a connection to a PostgreSQL database

PostgreSQL (http://www.postgres.org) is a BSD-licensed SQL database. It's large, fast, and can not be easily embedded inside other applications. Its databases are stored in files that belong to another process.

This class provides a VTK interface to PostgreSQL. You do need to download external libraries: we need a copy of PostgreSQL 8 (currently 8.2 or 8.3) so that we can link against the libpq C interface.

Thanks:
Thanks to David Thompson and Andy Wilson from Sandia National Laboratories for implementing this class.
See also:
vtkPostgreSQLQuery
Tests:
vtkPostgreSQLDatabase (Tests)

Definition at line 58 of file vtkPostgreSQLDatabase.h.


Public Types

typedef vtkSQLDatabase Superclass

Public Member Functions

virtual const char * GetClassName ()
virtual int IsA (const char *type)
void PrintSelf (ostream &os, vtkIndent indent)
bool Open (const char *password=0)
void Close ()
bool IsOpen ()
vtkSQLQueryGetQueryInstance ()
virtual bool HasError ()
const char * GetLastErrorText ()
virtual void SetPassword (const char *)
virtual vtkStdString GetURL ()
vtkStringArrayGetTables ()
vtkStringArrayGetRecord (const char *table)
bool IsSupported (int feature)
vtkStringArrayGetDatabases ()
bool CreateDatabase (const char *dbName, bool dropExisting=false)
bool DropDatabase (const char *dbName)
virtual char * GetDatabaseType ()
virtual void SetHostName (const char *)
virtual char * GetHostName ()
virtual void SetUser (const char *)
virtual char * GetUser ()
virtual void SetDatabaseName (const char *)
virtual char * GetDatabaseName ()
virtual void SetConnectOptions (const char *)
virtual char * GetConnectOptions ()
virtual void SetServerPort (int)
virtual int GetServerPortMinValue ()
virtual int GetServerPortMaxValue ()
virtual int GetServerPort ()
virtual vtkStdString GetColumnSpecification (vtkSQLDatabaseSchema *schema, int tblHandle, int colHandle)

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkPostgreSQLDatabaseSafeDownCast (vtkObject *o)
static vtkPostgreSQLDatabaseNew ()

Protected Member Functions

 vtkPostgreSQLDatabase ()
 ~vtkPostgreSQLDatabase ()
void UpdateDataTypeMap ()
virtual bool ParseURL (const char *url)
virtual void SetDatabaseType (const char *)
virtual void SetLastErrorText (const char *)
void NullTrailingWhitespace (char *msg)
bool OpenInternal (const char *connectionOptions)

Protected Attributes

vtkTimeStamp URLMTime
vtkPostgreSQLDatabasePrivateConnection
vtkTimeStamp ConnectionMTime
vtkStringArrayTables
char * DatabaseType
char * HostName
char * User
char * Password
char * DatabaseName
int ServerPort
char * ConnectOptions
char * LastErrorText

Friends

class vtkPostgreSQLQuery
class vtkPostgreSQLQueryPrivate

Member Typedef Documentation

Reimplemented from vtkSQLDatabase.

Definition at line 66 of file vtkPostgreSQLDatabase.h.


Constructor & Destructor Documentation

vtkPostgreSQLDatabase::vtkPostgreSQLDatabase (  )  [protected]

vtkPostgreSQLDatabase::~vtkPostgreSQLDatabase (  )  [protected]


Member Function Documentation

virtual const char* vtkPostgreSQLDatabase::GetClassName (  )  [virtual]

Reimplemented from vtkSQLDatabase.

static int vtkPostgreSQLDatabase::IsTypeOf ( const char *  name  )  [static]

Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkSQLDatabase.

virtual int vtkPostgreSQLDatabase::IsA ( const char *  name  )  [virtual]

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkSQLDatabase.

static vtkPostgreSQLDatabase* vtkPostgreSQLDatabase::SafeDownCast ( vtkObject o  )  [static]

Reimplemented from vtkSQLDatabase.

void vtkPostgreSQLDatabase::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkSQLDatabase.

static vtkPostgreSQLDatabase* vtkPostgreSQLDatabase::New (  )  [static]

Create an object with Debug turned off, modified time initialized to zero, and reference counting on.

Reimplemented from vtkObject.

bool vtkPostgreSQLDatabase::Open ( const char *  password = 0  )  [virtual]

Open a new connection to the database. You need to set the filename before calling this function. Returns true if the database was opened successfully; false otherwise.

Implements vtkSQLDatabase.

void vtkPostgreSQLDatabase::Close (  )  [virtual]

Close the connection to the database.

Implements vtkSQLDatabase.

bool vtkPostgreSQLDatabase::IsOpen (  )  [virtual]

Return whether the database has an open connection

Implements vtkSQLDatabase.

vtkSQLQuery* vtkPostgreSQLDatabase::GetQueryInstance (  )  [virtual]

Return an empty query on this database.

Implements vtkSQLDatabase.

virtual bool vtkPostgreSQLDatabase::HasError (  )  [virtual]

Did the last operation generate an error

Implements vtkSQLDatabase.

const char* vtkPostgreSQLDatabase::GetLastErrorText (  )  [virtual]

Get the last error text from the database

Implements vtkSQLDatabase.

virtual char* vtkPostgreSQLDatabase::GetDatabaseType (  )  [virtual]

String representing database type (e.g. "psql").

Implements vtkSQLDatabase.

virtual void vtkPostgreSQLDatabase::SetHostName ( const char *   )  [virtual]

The database server host name.

virtual char* vtkPostgreSQLDatabase::GetHostName (  )  [virtual]

The database server host name.

virtual void vtkPostgreSQLDatabase::SetUser ( const char *   )  [virtual]

The user name for connecting to the database server.

virtual char* vtkPostgreSQLDatabase::GetUser (  )  [virtual]

The user name for connecting to the database server.

virtual void vtkPostgreSQLDatabase::SetPassword ( const char *   )  [virtual]

The user's password for connecting to the database server.

virtual void vtkPostgreSQLDatabase::SetDatabaseName ( const char *   )  [virtual]

The name of the database to connect to.

virtual char* vtkPostgreSQLDatabase::GetDatabaseName (  )  [virtual]

The name of the database to connect to.

virtual void vtkPostgreSQLDatabase::SetConnectOptions ( const char *   )  [virtual]

Additional options for the database.

virtual char* vtkPostgreSQLDatabase::GetConnectOptions (  )  [virtual]

Additional options for the database.

void vtkPostgreSQLDatabase::SetServerPort ( int  _arg  )  [inline, virtual]

The port used for connecting to the database.

Definition at line 250 of file vtkPostgreSQLDatabase.h.

virtual int vtkPostgreSQLDatabase::GetServerPortMinValue (  )  [inline, virtual]

The port used for connecting to the database.

Definition at line 125 of file vtkPostgreSQLDatabase.h.

virtual int vtkPostgreSQLDatabase::GetServerPortMaxValue (  )  [inline, virtual]

The port used for connecting to the database.

Definition at line 129 of file vtkPostgreSQLDatabase.h.

virtual int vtkPostgreSQLDatabase::GetServerPort (  )  [virtual]

The port used for connecting to the database.

virtual vtkStdString vtkPostgreSQLDatabase::GetURL (  )  [virtual]

Get a URL referencing the current database connection. This is not well-defined if the HostName and DatabaseName have not been set. The URL will be of the form 'psql://'[username[':'password]'@']hostname[':'port]'/'database .

Implements vtkSQLDatabase.

vtkStringArray* vtkPostgreSQLDatabase::GetTables (  )  [virtual]

Get the list of tables from the database

Implements vtkSQLDatabase.

vtkStringArray* vtkPostgreSQLDatabase::GetRecord ( const char *  table  )  [virtual]

Get the list of fields for a particular table

Implements vtkSQLDatabase.

bool vtkPostgreSQLDatabase::IsSupported ( int  feature  ) 

Return whether a feature is supported by the database.

vtkStringArray* vtkPostgreSQLDatabase::GetDatabases (  ) 

Return a list of databases on the server.

bool vtkPostgreSQLDatabase::CreateDatabase ( const char *  dbName,
bool  dropExisting = false 
)

Create a new database, optionally dropping any existing database of the same name. Returns true when the database is properly created and false on failure.

bool vtkPostgreSQLDatabase::DropDatabase ( const char *  dbName  ) 

Drop a database if it exists. Returns true on success and false on failure.

virtual vtkStdString vtkPostgreSQLDatabase::GetColumnSpecification ( vtkSQLDatabaseSchema schema,
int  tblHandle,
int  colHandle 
) [virtual]

Return the SQL string with the syntax to create a column inside a "CREATE TABLE" SQL statement. NB: this method implements the PostgreSQL-specific syntax: <column name>=""> <column type>=""> <column attributes>="">

Reimplemented from vtkSQLDatabase.

void vtkPostgreSQLDatabase::UpdateDataTypeMap (  )  [protected]

Create or refresh the map from Postgres column types to VTK array types. Postgres defines a table for types so that users may define types. This adaptor does not support user-defined types or even all of the default types defined by Postgres (some are inherently difficult to translate into VTK since Postgres allows columns to have composite types, vector-valued types, and extended precision types that vtkVariant does not support. This routine examines the pg_types table to get a map from Postgres column type IDs (stored as OIDs) to VTK array types. It is called whenever a new database connection is initiated.

virtual bool vtkPostgreSQLDatabase::ParseURL ( const char *  url  )  [protected, virtual]

Overridden to determine connection parameters given the URL. This is called by CreateFromURL() to initialize the instance. Look at CreateFromURL() for details about the URL format.

Implements vtkSQLDatabase.

virtual void vtkPostgreSQLDatabase::SetDatabaseType ( const char *   )  [protected, virtual]

virtual void vtkPostgreSQLDatabase::SetLastErrorText ( const char *   )  [protected, virtual]

void vtkPostgreSQLDatabase::NullTrailingWhitespace ( char *  msg  )  [protected]

bool vtkPostgreSQLDatabase::OpenInternal ( const char *  connectionOptions  )  [protected]


Friends And Related Function Documentation

friend class vtkPostgreSQLQuery [friend]

Definition at line 61 of file vtkPostgreSQLDatabase.h.

friend class vtkPostgreSQLQueryPrivate [friend]

Definition at line 62 of file vtkPostgreSQLDatabase.h.


Member Data Documentation

Definition at line 199 of file vtkPostgreSQLDatabase.h.

Definition at line 200 of file vtkPostgreSQLDatabase.h.

Definition at line 201 of file vtkPostgreSQLDatabase.h.

Definition at line 202 of file vtkPostgreSQLDatabase.h.

Definition at line 203 of file vtkPostgreSQLDatabase.h.

Definition at line 204 of file vtkPostgreSQLDatabase.h.

char* vtkPostgreSQLDatabase::User [protected]

Definition at line 205 of file vtkPostgreSQLDatabase.h.

Definition at line 206 of file vtkPostgreSQLDatabase.h.

Definition at line 207 of file vtkPostgreSQLDatabase.h.

Definition at line 208 of file vtkPostgreSQLDatabase.h.

Definition at line 209 of file vtkPostgreSQLDatabase.h.

Definition at line 210 of file vtkPostgreSQLDatabase.h.


The documentation for this class was generated from the following file:

Generated on Wed Aug 24 11:57:39 2011 for VTK by  doxygen 1.5.6