libpqxx 3.1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

basic_connection.hxx
1 /*-------------------------------------------------------------------------
2 *
3 * FILE
4 * pqxx/basic_connection.hxx
5 *
6 * DESCRIPTION
7 * definition of the pqxx::basic_connection class template
8 * Instantiations of basic_connection bring connections and policies together
9 * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/connection_base instead.
10 *
11 * Copyright (c) 2006-2009, Jeroen T. Vermeulen <jtv@xs4all.nl>
12 *
13 * See COPYING for copyright license. If you did not receive a file called
14 * COPYING with this source code, please notify the distributor of this mistake,
15 * or contact the author.
16 *
17 *-------------------------------------------------------------------------
18 */
19 #ifndef PQXX_H_BASIC_CONNECTION
20 #define PQXX_H_BASIC_CONNECTION
21
22 #include "pqxx/compiler-public.hxx"
23 #include "pqxx/compiler-internal-pre.hxx"
24
25 #include <memory>
26 #include <string>
27
28 #include "pqxx/connection_base"
29
30 namespace pqxx
31 {
32
33 // TODO: Also mix in thread synchronization policy here!
35
49 template<typename CONNECTPOLICY> class basic_connection :
50 public connection_base
51 {
52 public:
53 basic_connection() :
54 connection_base(m_policy),
55 m_options(PGSTD::string()),
56 m_policy(m_options)
57 { init(); }
58
59 explicit basic_connection(const PGSTD::string &opt) :
60 connection_base(m_policy), m_options(opt), m_policy(m_options) {init();}
61
62 explicit basic_connection(const char opt[]) :
63 connection_base(m_policy),
64 m_options(opt?opt:PGSTD::string()),
65 m_policy(m_options)
66 { init(); }
67
68 ~basic_connection() throw ()
69 {
70 #ifdef PQXX_QUIET_DESTRUCTORS
71 PGSTD::auto_ptr<noticer> n(new nonnoticer);
72 set_noticer(n);
73 #endif
74 close();
75 }
76
77 const PGSTD::string &options() const throw () //[t1]
78 {return m_policy.options();}
79
80 private:
82 PGSTD::string m_options;
84 CONNECTPOLICY m_policy;
85 };
86
87 } // namespace
88
89 #include "pqxx/compiler-internal-post.hxx"
90
91 #endif
92