Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

connection.hxx

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/connection.hxx
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::connection and pqxx::lazyconnection classes.
00008  *   Different ways of setting up a backend connection.
00009  *   DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/connection instead.
00010  *
00011  * Copyright (c) 2001-2005, Jeroen T. Vermeulen <jtv@xs4all.nl>
00012  *
00013  * See COPYING for copyright license.  If you did not receive a file called
00014  * COPYING with this source code, please notify the distributor of this mistake,
00015  * or contact the author.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #include "pqxx/libcompiler.h"
00020 
00021 #include "pqxx/connection_base"
00022 
00023 
00024 /* Methods tested in eg. self-test program test001 are marked with "//[t1]"
00025  */
00026 
00027 namespace pqxx
00028 {
00029 
00031 
00047 class PQXX_LIBEXPORT connection : public connection_base
00048 {
00049 public:
00051 
00055   connection();                                                         //[t1]
00056 
00058 
00068   explicit connection(const PGSTD::string &ConnInfo);                   //[t2]
00069 
00071 
00079   explicit connection(const char ConnInfo[]);                           //[t3]
00080 
00081   virtual ~connection() throw ();
00082 
00083 private:
00084   virtual void startconnect() { do_startconnect(); }
00085   virtual void completeconnect() {}
00086 
00087   void do_startconnect();
00088 };
00089 
00090 
00092 
00100 class PQXX_LIBEXPORT lazyconnection : public connection_base
00101 {
00102 public:
00104   lazyconnection() : connection_base(0) {}                              //[t23]
00105 
00107 
00115   explicit lazyconnection(const PGSTD::string &ConnInfo) :              //[t21]
00116         connection_base(ConnInfo) {}
00117 
00119 
00128   explicit lazyconnection(const char ConnInfo[]) :                      //[t22]
00129         connection_base(ConnInfo) {}
00130 
00131   virtual ~lazyconnection() throw ();
00132 
00133 private:
00134   virtual void startconnect() {}
00135   virtual void completeconnect();
00136 };
00137 
00138 
00140 
00146 class PQXX_LIBEXPORT asyncconnection : public connection_base
00147 {
00148 public:
00150   asyncconnection();                                                    //[t63]
00151 
00153 
00161   explicit asyncconnection(const PGSTD::string &ConnInfo);              //[t65]
00162 
00164 
00173   explicit asyncconnection(const char ConnInfo[]);                      //[t64]
00174 
00175   virtual ~asyncconnection() throw ();
00176 
00177 private:
00178   virtual void startconnect() { do_startconnect(); }
00179   virtual void completeconnect();
00180   virtual void dropconnect() throw () { do_dropconnect(); }
00181 
00182   void do_startconnect();
00183   void do_dropconnect() throw () { m_connecting = false; }
00184 
00186   bool m_connecting;
00187 };
00188 
00189 
00191 
00196 class PQXX_LIBEXPORT nullconnection : public connection_base
00197 {
00198 public:
00200   nullconnection() : connection_base("") {}                             //[t0]
00202   explicit nullconnection(const PGSTD::string &c) :                     //[t0]
00203         connection_base(c) {}
00205   explicit nullconnection(const char c[]) :                             //[t0]
00206         connection_base(c) {}
00207 
00208   virtual ~nullconnection() throw ();
00209 
00210 private:
00211   virtual void startconnect() {}
00212   virtual void completeconnect() {}
00213 };
00214 
00215 }
00216 
00217 /* On Windows, any user-allocated notice processors, triggers etc. must be
00218  * deallocated in the user context.  Therefore we want these destructors to be
00219  * inlined.
00220  * On SUN's CC 5.1 compiler, on the other hand, there will be problems if we
00221  * don't have out-of-line virtual destructors in the leaf classes, so we must
00222  * not inline them.
00223  */
00224 #ifdef _WIN32
00225 inline pqxx::connection::~connection() throw () { close(); }
00226 inline pqxx::lazyconnection::~lazyconnection() throw () { close(); }
00227 inline pqxx::asyncconnection::~asyncconnection() throw () {do_dropconnect();close();}
00228 #endif
00229 

Generated on Sat Mar 19 18:42:42 2005 for libpqxx by  doxygen 1.4.1