/sqlite3cc

To get this branch, use:
bzr branch http://bzr.ed.am/sqlite3cc

« back to all changes in this revision

Viewing changes to include/sqlite3cc/transaction.h

  • Committer: edam
  • Date: 2010-02-02 16:13:16 UTC
  • Revision ID: edam@waxworlds.org-20100202161316-tceybmdeotltldow
- print "ok" when test program is successful!
- renamed 'Makefile's 'subdir.mk' so that the edam.mk build system will live happily along side an autotools build system

Show diffs side-by-side

added added

removed removed

25
25
 
26
26
 
27
27
#include <boost/utility.hpp>
28
 
#include <string>
29
28
 
30
29
 
31
30
namespace sqlite
35
34
class database;
36
35
 
37
36
 
38
 
/**
39
 
 * A basic (default, deferred) transaction.
40
 
 */
41
37
class basic_transaction
42
38
        :
43
39
        private boost::noncopyable
76
72
//                                                                implementation
77
73
protected:
78
74
 
79
 
        /** close any in-progress statements */
80
 
        void invalidate_queries();
81
 
 
82
 
        /** the database on which to act */
 
75
        /* the database on which to act */
83
76
        database &_database;
84
77
 
85
78
};
88
81
////////////////////////////////////////////////////////////////////////////////
89
82
 
90
83
 
91
 
/**
92
 
 * An exclusive transaction
93
 
 */
94
 
class immediate_transaction
95
 
        :
96
 
        public basic_transaction
97
 
{
98
 
//______________________________________________________________________________
99
 
//                                                                 instantiation
100
 
public:
101
 
 
102
 
        /**
103
 
         * Constructor that provides a database upon which to act
104
 
         * @param database a database
105
 
         */
106
 
        explicit immediate_transaction(
107
 
                database &database );
108
 
 
109
 
//______________________________________________________________________________
110
 
//                                                              public interface
111
 
public:
112
 
 
113
 
        /**
114
 
         * Begin the transaction
115
 
         */
116
 
        virtual void begin();
117
 
 
118
 
};
119
 
 
120
 
 
121
 
////////////////////////////////////////////////////////////////////////////////
122
 
 
123
 
 
124
 
/**
125
 
 * An exclusive transaction
126
 
 */
127
84
class exclusive_transaction
128
85
        :
129
86
        public basic_transaction
154
111
////////////////////////////////////////////////////////////////////////////////
155
112
 
156
113
 
157
 
/**
158
 
 * A recursive transaction, allowing transactions to be nested.
159
 
 */
160
114
class recursive_transaction
161
115
        :
162
116
        public basic_transaction
204
158
////////////////////////////////////////////////////////////////////////////////
205
159
 
206
160
 
207
 
/**
208
 
 * A scope guard, or sentinel for use with one of the transaction classes.
209
 
 */
210
161
template< class T = basic_transaction >
211
162
class transaction_guard
212
163
        :
231
182
 
232
183
        ~transaction_guard()
233
184
        {
234
 
                if( !_released ) {
235
 
                        try {
236
 
                                _transaction.rollback();
237
 
                        }
238
 
                        catch( ... ) {
239
 
                        }
240
 
                }
 
185
                if( !_released )
 
186
                        _transaction.rollback();
241
187
        }
242
188
 
243
189
//______________________________________________________________________________
259
205
//                                                                implementation
260
206
protected:
261
207
 
262
 
        /** the transaction */
 
208
        /* the transaction */
263
209
        T _transaction;
264
210
 
265
 
        /** have we released the transaction yet? */
 
211
        /* have we released the transaction yet? */
266
212
        bool _released;
267
213
 
268
214
};