/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-07-27 15:46:42 UTC
  • Revision ID: edam@waxworlds.org-20100727154642-1uxrjkpxhp7xl6hq
- moved null_t, exec_t and set_index_t to detail namespace so only their extern instantiations are in the main namespace
- added immediate transation

Show diffs side-by-side

added added

removed removed

25
25
 
26
26
 
27
27
#include <boost/utility.hpp>
 
28
#include <string>
28
29
 
29
30
 
30
31
namespace sqlite
34
35
class database;
35
36
 
36
37
 
 
38
/**
 
39
 * A basic (default, deferred) transaction.
 
40
 */
37
41
class basic_transaction
38
42
        :
39
43
        private boost::noncopyable
81
85
////////////////////////////////////////////////////////////////////////////////
82
86
 
83
87
 
 
88
/**
 
89
 * An exclusive transaction
 
90
 */
 
91
class immediate_transaction
 
92
        :
 
93
        public basic_transaction
 
94
{
 
95
//______________________________________________________________________________
 
96
//                                                                 instantiation
 
97
public:
 
98
 
 
99
        /**
 
100
         * Constructor that provides a database upon which to act
 
101
         * @param database a database
 
102
         */
 
103
        explicit immediate_transaction(
 
104
                database &database );
 
105
 
 
106
//______________________________________________________________________________
 
107
//                                                              public interface
 
108
public:
 
109
 
 
110
        /**
 
111
         * Begin the transaction
 
112
         */
 
113
        virtual void begin();
 
114
 
 
115
};
 
116
 
 
117
 
 
118
////////////////////////////////////////////////////////////////////////////////
 
119
 
 
120
 
 
121
/**
 
122
 * An exclusive transaction
 
123
 */
84
124
class exclusive_transaction
85
125
        :
86
126
        public basic_transaction
111
151
////////////////////////////////////////////////////////////////////////////////
112
152
 
113
153
 
 
154
/**
 
155
 * A recursive transaction, allowing transactions to be nested.
 
156
 */
114
157
class recursive_transaction
115
158
        :
116
159
        public basic_transaction
158
201
////////////////////////////////////////////////////////////////////////////////
159
202
 
160
203
 
 
204
/**
 
205
 * A scope guard, or sentinel for use with one of the transaction classes.
 
206
 */
161
207
template< class T = basic_transaction >
162
208
class transaction_guard
163
209
        :
182
228
 
183
229
        ~transaction_guard()
184
230
        {
185
 
                if( !_released )
186
 
                        _transaction.rollback();
 
231
                if( !_released ) {
 
232
                        try {
 
233
                                _transaction.rollback();
 
234
                        }
 
235
                        catch( ... ) {
 
236
                        }
 
237
                }
187
238
        }
188
239
 
189
240
//______________________________________________________________________________