libpqxx  5.0
connection.hxx
1 /*-------------------------------------------------------------------------
2  *
3  * FILE
4  * pqxx/connection.hxx
5  *
6  * DESCRIPTION
7  * definition of the pqxx::connection and pqxx::lazyconnection classes.
8  * Different ways of setting up a backend connection.
9  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/connection instead.
10  *
11  * Copyright (c) 2001-2015, 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_CONNECTION
20 #define PQXX_H_CONNECTION
21 
22 #include "pqxx/compiler-public.hxx"
23 #include "pqxx/compiler-internal-pre.hxx"
24 
25 #include "pqxx/connectionpolicy"
26 #include "pqxx/basic_connection"
27 
28 namespace pqxx
29 {
30 
73 
84 class PQXX_LIBEXPORT connect_direct : public connectionpolicy
85 {
86 public:
87  explicit connect_direct(const std::string &opts) : connectionpolicy(opts) {}
88  virtual handle do_startconnect(handle) PQXX_OVERRIDE;
89 };
90 
93 
94 
96 
100 class PQXX_LIBEXPORT connect_lazy : public connectionpolicy
101 {
102 public:
103  explicit connect_lazy(const std::string &opts) : connectionpolicy(opts) {}
104  virtual handle do_completeconnect(handle) PQXX_OVERRIDE;
105 };
106 
107 
110 
111 
113 
119 class PQXX_LIBEXPORT connect_async : public connectionpolicy
120 {
121 public:
122  explicit connect_async(const std::string &opts);
123  virtual handle do_startconnect(handle) PQXX_OVERRIDE;
124  virtual handle do_completeconnect(handle) PQXX_OVERRIDE;
125  virtual handle do_dropconnect(handle) PQXX_NOEXCEPT PQXX_OVERRIDE;
126  virtual bool is_ready(handle) const PQXX_NOEXCEPT PQXX_OVERRIDE;
127 
128 private:
130  bool m_connecting;
131 };
132 
133 
136 
137 
139 
143 class PQXX_LIBEXPORT connect_null : public connectionpolicy
144 {
145 public:
146  explicit connect_null(const std::string &opts) : connectionpolicy(opts) {}
147 };
148 
149 
152 
157 }
158 
159 #include "pqxx/compiler-internal-post.hxx"
160 
161 #endif
162 
basic_connection< connect_null > nullconnection
A &quot;dummy&quot; connection type: don&#39;t connect to any database at all.
Definition: connection.hxx:151
Lazy connection policy; causes connection to be deferred until first use.
Definition: connection.hxx:100
connect_lazy(const std::string &opts)
Definition: connection.hxx:103
The ultimate template that defines a connection type.
Definition: basic_connection.hxx:50
Nonfunctional, always-down connection policy for testing/debugging purposes.
Definition: connection.hxx:143
Connection policy; creates an immediate connection to a database.
Definition: connection.hxx:84
basic_connection< connect_async > asyncconnection
&quot;Asynchronous&quot; connection type: start connecting, but don&#39;t wait for it
Definition: connection.hxx:135
connect_null(const std::string &opts)
Definition: connection.hxx:146
Asynchronous connection policy; connects &quot;in the background&quot;.
Definition: connection.hxx:119
internal::pq::PGconn * handle
Definition: connectionpolicy.hxx:42
Definition: connectionpolicy.hxx:39
connect_direct(const std::string &opts)
Definition: connection.hxx:87