Kea 2.5.8
isc::db::PgSqlHolder Class Reference

Postgresql connection handle Holder. More...

#include <pgsql_connection.h>

+ Inheritance diagram for isc::db::PgSqlHolder:

Public Member Functions

 PgSqlHolder ()
 Constructor.
 
 ~PgSqlHolder ()
 Destructor.
 
 operator bool () const
 Boolean Operator.
 
 operator PGconn * () const
 Conversion Operator.
 
void setConnection (PGconn *connection)
 Sets the connection to the value given.
 

Detailed Description

Postgresql connection handle Holder.

Small RAII object for safer initialization, will close the database connection upon destruction. This means that if an exception is thrown during database initialization, resources allocated to the database are guaranteed to be freed.

It makes no sense to copy an object of this class. After the copy, both objects would contain pointers to the same PgSql context object. The destruction of one would invalid the context in the remaining object. For this reason, the class is declared noncopyable.

Definition at line 79 of file pgsql_connection.h.

Constructor & Destructor Documentation

◆ PgSqlHolder()

isc::db::PgSqlHolder::PgSqlHolder ( )
inline

Constructor.

Sets the Postgresql API connector handle to NULL.

Definition at line 86 of file pgsql_connection.h.

◆ ~PgSqlHolder()

isc::db::PgSqlHolder::~PgSqlHolder ( )
inline

Destructor.

Frees up resources allocated by the connection.

Definition at line 92 of file pgsql_connection.h.

Member Function Documentation

◆ operator bool()

isc::db::PgSqlHolder::operator bool ( ) const
inline

Boolean Operator.

Allows testing the connection for emptiness: "if (holder)"

Definition at line 122 of file pgsql_connection.h.

◆ operator PGconn *()

isc::db::PgSqlHolder::operator PGconn * ( ) const
inline

Conversion Operator.

Allows the PgSqlHolder object to be passed as the context argument to PQxxxx functions.

Definition at line 115 of file pgsql_connection.h.

◆ setConnection()

void isc::db::PgSqlHolder::setConnection ( PGconn *  connection)
inline

Sets the connection to the value given.

Parameters
connection- pointer to the Postgresql connection instance

Definition at line 101 of file pgsql_connection.h.


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