basic_connection.hxx

00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/basic_connection.hxx
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::basic_connection class template
00008  *   Instantiations of basic_connection bring connections and policies together
00009  *   DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/connection_base instead.
00010  *
00011  * Copyright (c) 2006-2008, 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 #ifndef PQXX_H_BASIC_CONNECTION
00020 #define PQXX_H_BASIC_CONNECTION
00021 
00022 #include "pqxx/compiler-public.hxx"
00023 #include "pqxx/compiler-internal-pre.hxx"
00024 
00025 #include <string>
00026 
00027 #include "pqxx/connection_base"
00028 
00029 namespace pqxx
00030 {
00031 
00032 // TODO: Also mix in thread synchronization policy here!
00034 
00048 template<typename CONNECTPOLICY> class basic_connection :
00049   public connection_base
00050 {
00051 public:
00052   basic_connection() :
00053     connection_base(m_policy),
00054     m_options(PGSTD::string()),
00055     m_policy(m_options)
00056         { init(); }
00057 
00058   explicit basic_connection(const PGSTD::string &opt) :
00059     connection_base(m_policy), m_options(opt), m_policy(m_options) {init();}
00060 
00061   explicit basic_connection(const char opt[]) :
00062     connection_base(m_policy),
00063     m_options(opt?opt:PGSTD::string()),
00064     m_policy(m_options)
00065         { init(); }
00066 
00067   ~basic_connection() throw ()
00068   {
00069 #ifdef PQXX_QUIET_DESTRUCTORS
00070     PGSTD::auto_ptr<noticer> n(new nonnoticer);
00071     set_noticer(n);
00072 #endif
00073     close();
00074   }
00075 
00076   const PGSTD::string &options() const throw ()                         //[t1]
00077         {return m_policy.options();}
00078 
00079 private:
00081   PGSTD::string m_options;
00083   CONNECTPOLICY m_policy;
00084 };
00085 
00086 } // namespace
00087 
00088 #include "pqxx/compiler-internal-post.hxx"
00089 
00090 #endif
00091 

Generated on Sat Aug 15 00:16:49 2009 for libpqxx by  doxygen 1.5.8