db_planner::DatabaseConnection Class Reference

#include <database.h>

List of all members.

Public Member Functions

 DatabaseConnection (const string &host_name, const int port, const string &user_name, const string &password, const string &database_name, const string &connection_type="QPSQL")
 Constructor that opens a database connection.
bool isConnected () const
 Shows if the connection to the database was successful.
bool Query (const string &sql, Table *table=NULL) const
 Queries the database with a SQL string and populates a Table with the results.
virtual ~DatabaseConnection ()
 The destructor of the DatabaseConnection closes the underlying database connection.

Private Attributes

bool connected_
 Shows if the connection was successful.
QSqlDatabase db_
 The QT database object that this manages.

Static Private Attributes

static int connection_num_ = 0
 A counter to distinguish connections.

Detailed Description

A RAII object for managing a database connection. Each database connection is named, so multiply connections can exist by having multiple objects of this type. Each object maintains all the information about its own connection and queries.

Definition at line 87 of file database.h.


Constructor & Destructor Documentation

db_planner::DatabaseConnection::DatabaseConnection ( const string &  host_name,
const int  port,
const string &  user_name,
const string &  password,
const string &  database_name,
const string &  connection_type = "QPSQL" 
)

Constructor that opens a database connection.

Multiple connections to the database can coexist as separate DatabaseConnection objects without any extra work.

Definition at line 72 of file database.cpp.

virtual db_planner::DatabaseConnection::~DatabaseConnection (  )  [inline, virtual]

The destructor of the DatabaseConnection closes the underlying database connection.

Definition at line 103 of file database.h.


Member Function Documentation

bool db_planner::DatabaseConnection::isConnected (  )  const [inline]

Shows if the connection to the database was successful.

Definition at line 110 of file database.h.

bool db_planner::DatabaseConnection::Query ( const string &  sql,
Table table = NULL 
) const

Queries the database with a SQL string and populates a Table with the results.

Query the database using a SQL string and store the results in a provided Table.

If the query succeeds the table is populated with the results. If not, the function returns false and table's contents are undefined.

If the query is not expected to return any results, the table can be NULL

Definition at line 98 of file database.cpp.


Member Data Documentation

Shows if the connection was successful.

Definition at line 94 of file database.h.

A counter to distinguish connections.

Definition at line 92 of file database.h.

QSqlDatabase db_planner::DatabaseConnection::db_ [private]

The QT database object that this manages.

Definition at line 90 of file database.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


graspit
Author(s):
autogenerated on Wed Jan 25 11:00:32 2012