libpqxx 4.0.1

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

transaction.hxx
1 /*-------------------------------------------------------------------------
2 *
3 * FILE
4 * pqxx/transaction.hxx
5 *
6 * DESCRIPTION
7 * definition of the pqxx::transaction class.
8 * pqxx::transaction represents a standard database transaction
9 * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/transaction instead.
10 *
11 * Copyright (c) 2001-2011, 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_TRANSACTION
20 #define PQXX_H_TRANSACTION
21
22 #include "pqxx/compiler-public.hxx"
23 #include "pqxx/compiler-internal-pre.hxx"
24
25 #include "pqxx/dbtransaction"
26
27 #ifdef PQXX_QUIET_DESTRUCTORS
28 #include "pqxx/errorhandler"
29 #endif
30
31
32
33 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
34 */
35
36
37 namespace pqxx
38 {
39
44
45 class PQXX_LIBEXPORT basic_transaction : public dbtransaction
46 {
47 protected:
48 basic_transaction( //[t1]
49 connection_base &C,
50 const PGSTD::string &IsolationLevel,
51 readwrite_policy);
52
53 private:
54 virtual void do_commit(); //[t1]
55 };
56
57
59
87 template<
88 isolation_level ISOLATIONLEVEL=read_committed,
89 readwrite_policy READWRITE=read_write>
90 class transaction : public basic_transaction
91 {
92 public:
93 typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
94
96
101 explicit transaction(connection_base &C, const PGSTD::string &TName): //[t1]
102 namedclass(fullname("transaction", isolation_tag::name()), TName),
103 basic_transaction(C, isolation_tag::name(), READWRITE)
104 { Begin(); }
105
106 explicit transaction(connection_base &C) : //[t1]
107 namedclass(fullname("transaction", isolation_tag::name())),
108 basic_transaction(C, isolation_tag::name(), READWRITE)
109 { Begin(); }
110
111 virtual ~transaction() throw ()
112 {
113 #ifdef PQXX_QUIET_DESTRUCTORS
114 quiet_errorhandler quiet(conn());
115 #endif
116 End();
117 }
118 };
119
120
122 typedef transaction<> work;
123
125 typedef transaction<read_committed, read_only> read_transaction;
126
128
129 }
130
131
132 #include "pqxx/compiler-internal-post.hxx"
133
134 #endif
135