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/basic_connection instead.
00010  *
00011  * Copyright (c) 2006-2015, 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 
00031 namespace pqxx
00032 {
00033 
00034 // TODO: Also mix in thread synchronization policy here!
00036 
00050 template<typename CONNECTPOLICY> class basic_connection :
00051   public connection_base
00052 {
00053 public:
00054   basic_connection() :
00055     connection_base(m_policy),
00056     m_options(std::string()),
00057     m_policy(m_options)
00058         { init(); }
00059 
00060   explicit basic_connection(const std::string &opt) :
00061     connection_base(m_policy), m_options(opt), m_policy(m_options) {init();}
00062 
00063   explicit basic_connection(const char opt[]) :
00064     connection_base(m_policy),
00065     m_options(opt?opt:std::string()),
00066     m_policy(m_options)
00067         { init(); }
00068 
00069   ~basic_connection() PQXX_NOEXCEPT                                 { close(); }
00070 
00071   const std::string &options() const PQXX_NOEXCEPT                      //[t1]
00072         {return m_policy.options();}
00073 
00074 private:
00076   std::string m_options;
00078   CONNECTPOLICY m_policy;
00079 };
00080 
00081 } // namespace
00082 
00083 #include "pqxx/compiler-internal-post.hxx"
00084 
00085 #endif

Generated on 16 Mar 2017 for libpqxx by  doxygen 1.6.1