Main Page | Modules | 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 
00034 
00036 
00052 class PQXX_LIBEXPORT connection : public connection_base
00053 {
00054 public:
00056 
00060   connection();                                                         //[t1]
00061 
00063 
00073   explicit connection(const PGSTD::string &ConnInfo);                   //[t2]
00074 
00076 
00084   explicit connection(const char ConnInfo[]);                           //[t3]
00085 
00086   virtual ~connection() throw ();
00087 
00088 private:
00089   virtual void PQXX_PRIVATE startconnect() { do_startconnect(); }
00090   virtual void PQXX_PRIVATE completeconnect() {}
00091 
00092   void PQXX_PRIVATE do_startconnect();
00093 };
00094 
00095 
00097 
00105 class PQXX_LIBEXPORT lazyconnection : public connection_base
00106 {
00107 public:
00109   lazyconnection() : connection_base(0) {}                              //[t23]
00110 
00112 
00120   explicit lazyconnection(const PGSTD::string &ConnInfo) :              //[t21]
00121         connection_base(ConnInfo) {}
00122 
00124 
00133   explicit lazyconnection(const char ConnInfo[]) :                      //[t22]
00134         connection_base(ConnInfo) {}
00135 
00136   virtual ~lazyconnection() throw ();
00137 
00138 private:
00139   virtual void PQXX_PRIVATE startconnect() {}
00140   virtual void PQXX_PRIVATE completeconnect();
00141 };
00142 
00143 
00145 
00151 class PQXX_LIBEXPORT asyncconnection : public connection_base
00152 {
00153 public:
00155   asyncconnection();                                                    //[t63]
00156 
00158 
00166   explicit asyncconnection(const PGSTD::string &ConnInfo);              //[t65]
00167 
00169 
00178   explicit asyncconnection(const char ConnInfo[]);                      //[t64]
00179 
00180   virtual ~asyncconnection() throw ();
00181 
00182 private:
00183   virtual void PQXX_PRIVATE startconnect() { do_startconnect(); }
00184   virtual void PQXX_PRIVATE completeconnect();
00185   virtual void PQXX_PRIVATE dropconnect() throw () { do_dropconnect(); }
00186 
00187   void PQXX_PRIVATE do_startconnect();
00188   void PQXX_PRIVATE do_dropconnect() throw () { m_connecting = false; }
00189 
00191   bool m_connecting;
00192 };
00193 
00194 
00196 
00201 class PQXX_LIBEXPORT nullconnection : public connection_base
00202 {
00203 public:
00205   nullconnection() : connection_base("") {}                             //[t0]
00207   explicit nullconnection(const PGSTD::string &c) :                     //[t0]
00208         connection_base(c) {}
00210   explicit nullconnection(const char c[]) :                             //[t0]
00211         connection_base(c) {}
00212 
00213   virtual ~nullconnection() throw ();
00214 
00215 private:
00216   virtual void PQXX_PRIVATE startconnect() {}
00217   virtual void PQXX_PRIVATE completeconnect() {}
00218 };
00219 
00221 
00222 }
00223 
00224 /* On Windows, any user-allocated notice processors, triggers etc. must be
00225  * deallocated in the user context.  Therefore we want these destructors to be
00226  * inlined.
00227  * On SUN's CC 5.1 compiler, on the other hand, there will be problems if we
00228  * don't have out-of-line virtual destructors in the leaf classes, so we must
00229  * not inline them.
00230  */
00231 #ifdef _WIN32
00232 inline pqxx::connection::~connection() throw () { close(); }
00233 inline pqxx::lazyconnection::~lazyconnection() throw () { close(); }
00234 inline pqxx::asyncconnection::~asyncconnection() throw () {do_dropconnect();close();}
00235 #endif
00236 

Generated on Mon Oct 3 20:28:58 2005 for libpqxx by  doxygen 1.4.2