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-2009, 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 <memory> 00026 #include <string> 00027 00028 #include "pqxx/connection_base" 00029 00030 namespace pqxx 00031 { 00032 00033 // TODO: Also mix in thread synchronization policy here! 00035 00049 template<typename CONNECTPOLICY> class basic_connection : 00050 public connection_base 00051 { 00052 public: 00053 basic_connection() : 00054 connection_base(m_policy), 00055 m_options(PGSTD::string()), 00056 m_policy(m_options) 00057 { init(); } 00058 00059 explicit basic_connection(const PGSTD::string &opt) : 00060 connection_base(m_policy), m_options(opt), m_policy(m_options) {init();} 00061 00062 explicit basic_connection(const char opt[]) : 00063 connection_base(m_policy), 00064 m_options(opt?opt:PGSTD::string()), 00065 m_policy(m_options) 00066 { init(); } 00067 00068 ~basic_connection() throw () 00069 { 00070 #ifdef PQXX_QUIET_DESTRUCTORS 00071 PGSTD::auto_ptr<noticer> n(new nonnoticer); 00072 set_noticer(n); 00073 #endif 00074 close(); 00075 } 00076 00077 const PGSTD::string &options() const throw () //[t1] 00078 {return m_policy.options();} 00079 00080 private: 00082 PGSTD::string m_options; 00084 CONNECTPOLICY m_policy; 00085 }; 00086 00087 } // namespace 00088 00089 #include "pqxx/compiler-internal-post.hxx" 00090 00091 #endif 00092