27
27
#include <boost/utility.hpp>
39
private boost::noncopyable
41
//______________________________________________________________________________
46
* Constructor that provides a database upon which to act
47
* @param database a database
52
virtual ~transaction() throw( );
57
* Constructor that provides a way for deriving classes to override the SQL
58
* executed in beginning and rolling-back a transaction during construction
60
* @param database a database
61
* @param begin_sql the SQL statement used to begin the transaction
62
* @param rollback_sql the SQL statement used to rollback the transaction,
63
* or an empty string if the default is to be used.
67
const std::string &begin_sql,
68
const std::string &rollback_sql = "" );
70
//______________________________________________________________________________
42
* A basic (default, deferred) transaction.
44
class basic_transaction
46
private boost::noncopyable
48
//__________________________________________________________________________
53
* Constructor that provides a connection upon which to act
54
* @param connection a connection
56
explicit basic_transaction(
57
connection &connection );
59
//__________________________________________________________________________
64
* Begin the transaction
69
* Commit the transaction
71
virtual void commit();
74
* Rollback the transaction
76
virtual void rollback();
78
//__________________________________________________________________________
82
/** reset any in-progress statements */
83
void reset_active_queries();
85
/** the connection on which to act */
86
connection &_connection;
93
////////////////////////////////////////////////////////////////////////////////
97
* A deferred transaction (the default)
99
typedef detail::basic_transaction deferred_tranaction;
102
////////////////////////////////////////////////////////////////////////////////
106
* An immediate transaction
108
class immediate_transaction
110
public detail::basic_transaction
112
//______________________________________________________________________________
117
* Constructor that provides a connection upon which to act
118
* @param connection a connection
120
explicit immediate_transaction(
121
connection &connection );
123
//______________________________________________________________________________
128
* Begin the transaction
130
virtual void begin();
135
////////////////////////////////////////////////////////////////////////////////
139
* An exclusive transaction
141
class exclusive_transaction
143
public detail::basic_transaction
145
//______________________________________________________________________________
150
* Constructor that provides a connection upon which to act
151
* @param connection a connection
153
explicit exclusive_transaction(
154
connection &connection );
156
//______________________________________________________________________________
161
* Begin the transaction
163
virtual void begin();
168
////////////////////////////////////////////////////////////////////////////////
172
* A recursive transaction, allowing transactions to be nested.
174
class recursive_transaction
176
public detail::basic_transaction
178
//______________________________________________________________________________
183
* Constructor that provides a connection upon which to act
184
* @param connection a connection
186
explicit recursive_transaction(
187
connection &connection );
189
//______________________________________________________________________________
194
* Begin the transaction
196
virtual void begin();
74
199
* Commit the transaction
96
218
////////////////////////////////////////////////////////////////////////////////
99
class exclusive_transaction
222
* A scope guard (sentinel) for use with one of the transaction classes to
223
* provide RIAA-style transactions.
225
template< class T = deferred_tranaction >
226
class transaction_guard
228
private boost::noncopyable
103
230
//______________________________________________________________________________
108
* Constructor that provides a database upon which to act
109
* @param database a database
111
exclusive_transaction(
112
database &database );
235
* Constructor that provides a connection upon which to act
236
* @param connection a connection
238
explicit transaction_guard(
239
connection &connection )
241
_transaction( connection ),
244
_transaction.begin();
250
_transaction.rollback();
253
//______________________________________________________________________________
258
* Commit the transaction
263
_transaction.commit();
269
* Rollback the transaction early
274
_transaction.rollback();
279
//______________________________________________________________________________
283
/** the transaction */
286
/** have we released the transaction yet? */