46
47
* Constructor that provides a database upon which to act
47
48
* @param database a database
50
explicit basic_transaction(
50
51
database &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
53
//______________________________________________________________________________
71
54
// public interface
58
* Begin the transaction
74
63
* Commit the transaction
79
68
* Rollback the transaction
70
virtual void rollback();
83
72
//______________________________________________________________________________
76
/* the database on which to act */
88
77
database &_database;
90
/** the SQL used to rollback the transaction, or empty to use default */
91
std::string _rollback_sql;
99
85
class exclusive_transaction
103
//______________________________________________________________________________
108
* Constructor that provides a database upon which to act
109
* @param database a database
111
exclusive_transaction(
112
database &database );
87
public basic_transaction
89
//______________________________________________________________________________
94
* Constructor that provides a database upon which to act
95
* @param database a database
97
explicit exclusive_transaction(
100
//______________________________________________________________________________
105
* Begin the transaction
107
virtual void begin();
112
////////////////////////////////////////////////////////////////////////////////
115
class recursive_transaction
117
public basic_transaction
119
//______________________________________________________________________________
124
* Constructor that provides a database upon which to act
125
* @param database a database
127
explicit recursive_transaction(
128
database &database );
130
//______________________________________________________________________________
135
* Begin the transaction
137
virtual void begin();
140
* Commit the transaction
142
virtual void commit();
145
* Rollback the transaction
147
virtual void rollback();
149
//______________________________________________________________________________
153
/* this transaction's savepoint name */
154
std::string _sp_name;
159
////////////////////////////////////////////////////////////////////////////////
162
template< class T = basic_transaction >
163
class transaction_guard
165
private boost::noncopyable
167
//______________________________________________________________________________
172
* Constructor that provides a database upon which to act
173
* @param database a database
175
explicit transaction_guard(
178
_transaction( database ),
181
_transaction.begin();
188
_transaction.rollback();
195
//______________________________________________________________________________
200
* Commit the transaction
205
_transaction.commit();
210
//______________________________________________________________________________
214
/* the transaction */
217
/* have we released the transaction yet? */