libpqxx 3.1.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-2008, 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
28
29 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
30 */
31
32
33 namespace pqxx
34 {
35
40
41 class PQXX_LIBEXPORT basic_transaction : public dbtransaction
42 {
43 protected:
44 basic_transaction( //[t1]
45 connection_base &C,
46 const PGSTD::string &IsolationLevel,
47 readwrite_policy);
48
49 private:
50 virtual void do_commit(); //[t1]
51 };
52
53
55
83 template<
84 isolation_level ISOLATIONLEVEL=read_committed,
85 readwrite_policy READWRITE=read_write>
86 class transaction : public basic_transaction
87 {
88 public:
89 typedef isolation_traits<ISOLATIONLEVEL> isolation_tag;
90
92
97 explicit transaction(connection_base &C, const PGSTD::string &TName): //[t1]
98 namedclass(fullname("transaction", isolation_tag::name()), TName),
99 basic_transaction(C, isolation_tag::name(), READWRITE)
100 { Begin(); }
101
102 explicit transaction(connection_base &C) : //[t1]
103 namedclass(fullname("transaction", isolation_tag::name())),
104 basic_transaction(C, isolation_tag::name(), READWRITE)
105 { Begin(); }
106
107 virtual ~transaction() throw ()
108 {
109 #ifdef PQXX_QUIET_DESTRUCTORS
110 disable_noticer Quiet(conn());
111 #endif
112 End();
113 }
114 };
115
116
118 typedef transaction<> work;
119
121 typedef transaction<read_committed, read_only> read_transaction;
122
124
125 }
126
127
128 #include "pqxx/compiler-internal-post.hxx"
129
130 #endif
131