27
27
#include <boost/utility.hpp>
 
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
 
 
37
class basic_transaction
 
110
 
        public detail::basic_transaction
 
 
39
        private boost::noncopyable
 
112
41
//______________________________________________________________________________
 
117
 
         * Constructor that provides a connection upon which to act
 
118
 
         * @param connection a connection
 
 
46
         * Constructor that provides a database upon which to act
 
 
47
         * @param database a database
 
120
 
        explicit immediate_transaction(
 
121
 
                connection &connection );
 
 
49
        explicit basic_transaction(
 
123
52
//______________________________________________________________________________
 
124
53
//                                                              public interface
 
 
130
59
        virtual void begin();
 
 
62
         * Commit the transaction
 
 
64
        virtual void commit();
 
 
67
         * Rollback the transaction
 
 
69
        virtual void rollback();
 
 
71
//______________________________________________________________________________
 
 
75
        /* the database on which to act */
 
135
81
////////////////////////////////////////////////////////////////////////////////
 
139
 
 * An exclusive transaction
 
141
84
class exclusive_transaction
 
143
 
        public detail::basic_transaction
 
 
86
        public basic_transaction
 
145
88
//______________________________________________________________________________
 
150
 
         * Constructor that provides a connection upon which to act
 
151
 
         * @param connection a connection
 
 
93
         * Constructor that provides a database upon which to act
 
 
94
         * @param database a database
 
153
96
        explicit exclusive_transaction(
 
154
 
                connection &connection );
 
156
99
//______________________________________________________________________________
 
157
100
//                                                              public interface
 
 
168
111
////////////////////////////////////////////////////////////////////////////////
 
172
 
 * A recursive transaction, allowing transactions to be nested.
 
174
114
class recursive_transaction
 
176
 
        public detail::basic_transaction
 
 
116
        public basic_transaction
 
178
118
//______________________________________________________________________________
 
183
 
         * Constructor that provides a connection upon which to act
 
184
 
         * @param connection a connection
 
 
123
         * Constructor that provides a database upon which to act
 
 
124
         * @param database a database
 
186
126
        explicit recursive_transaction(
 
187
 
                connection &connection );
 
 
127
                database &database );
 
189
129
//______________________________________________________________________________
 
190
130
//                                                              public interface
 
 
218
158
////////////////////////////////////////////////////////////////////////////////
 
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 >
 
 
161
template< class T = basic_transaction >
 
226
162
class transaction_guard
 
228
164
        private boost::noncopyable
 
 
235
 
         * Constructor that provides a connection upon which to act
 
236
 
         * @param connection a connection
 
 
171
         * Constructor that provides a database upon which to act
 
 
172
         * @param database a database
 
238
174
        explicit transaction_guard(
 
239
 
                connection &connection )
 
241
 
                _transaction( connection ),
 
 
177
                _transaction( database ),
 
242
178
                _released( false )
 
244
180
                _transaction.begin();