/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: 2012-01-23 14:27:08 UTC
  • Revision ID: edam@waxworlds.org-20120123142708-w12277ptwtlspa6f
updated email and web addresses

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * transaction.h
3
3
 *
4
 
 * Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
 
4
 * Copyright (C) 2009 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of sqlite3cc (hereafter referred to as "this program").
7
 
 * See http://www.waxworlds.org/edam/software/sqlite3cc for more information.
8
 
 *
9
 
 * This program is free software: you can redistribute it and/or modify
10
 
 * it under the terms of the GNU Lesser General Public License as published
11
 
 * by the Free Software Foundation, either version 3 of the License, or
12
 
 * (at your option) any later version.
13
 
 *
14
 
 * This program is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU Lesser General Public License for more details.
 
7
 * See http://ed.am/dev/sqlite3cc for more information.
 
8
 *
 
9
 * This program is free software: you can redistribute it and/or modify it under
 
10
 * the terms of the GNU Lesser General Public License as published by the Free
 
11
 * Software Foundation, either version 3 of the License, or (at your option) any
 
12
 * later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
16
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 
17
 * details.
18
18
 *
19
19
 * You should have received a copy of the GNU Lesser General Public License
20
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
50
50
        public:
51
51
 
52
52
                /**
53
 
                 * Constructor that provides a connection upon which to act
 
53
                 * Constructor that provides a connection upon which to act.
 
54
                 *
54
55
                 * @param connection a connection
55
56
                 */
56
57
                explicit basic_transaction(
94
95
 
95
96
 
96
97
/**
97
 
 * A deferred transaction (the default)
 
98
 * A deferred transaction.
98
99
 */
99
 
typedef detail::basic_transaction deferred_tranaction;
 
100
typedef detail::basic_transaction deferred_transaction;
100
101
 
101
102
 
102
103
////////////////////////////////////////////////////////////////////////////////
103
104
 
104
105
 
105
106
/**
106
 
 * An immediate transaction
 
107
 * An immediate transaction.
107
108
 */
108
109
class immediate_transaction
109
110
        :
114
115
public:
115
116
 
116
117
        /**
117
 
         * Constructor that provides a connection upon which to act
 
118
         * Constructor that provides a connection upon which to act.
 
119
         *
118
120
         * @param connection a connection
119
121
         */
120
122
        explicit immediate_transaction(
125
127
public:
126
128
 
127
129
        /**
128
 
         * Begin the transaction
 
130
         * Begin the transaction.
129
131
         */
130
132
        virtual void begin();
131
133
 
136
138
 
137
139
 
138
140
/**
139
 
 * An exclusive transaction
 
141
 * An exclusive transaction.
140
142
 */
141
143
class exclusive_transaction
142
144
        :
147
149
public:
148
150
 
149
151
        /**
150
 
         * Constructor that provides a connection upon which to act
 
152
         * Constructor that provides a connection upon which to act.
 
153
         *
151
154
         * @param connection a connection
152
155
         */
153
156
        explicit exclusive_transaction(
180
183
public:
181
184
 
182
185
        /**
183
 
         * Constructor that provides a connection upon which to act
 
186
         * Constructor that provides a connection upon which to act.
 
187
         *
184
188
         * @param connection a connection
185
189
         */
186
190
        explicit recursive_transaction(
191
195
public:
192
196
 
193
197
        /**
194
 
         * Begin the transaction
 
198
         * Begin the transaction.
195
199
         */
196
200
        virtual void begin();
197
201
 
198
202
        /**
199
 
         * Commit the transaction
 
203
         * Commit the transaction.
200
204
         */
201
205
        virtual void commit();
202
206
 
203
207
        /**
204
 
         * Rollback the transaction
 
208
         * Rollback the transaction.
205
209
         */
206
210
        virtual void rollback();
207
211
 
220
224
 
221
225
/**
222
226
 * A scope guard (sentinel) for use with one of the transaction classes to
223
 
 * provide RIAA-style transactions.
 
227
 * provide RAII-style transactions.  It defaults to using deferred transactions.
224
228
 */
225
 
template< class T = deferred_tranaction >
 
229
template< class T = deferred_transaction >
226
230
class transaction_guard
227
231
        :
228
232
        private boost::noncopyable
232
236
public:
233
237
 
234
238
        /**
235
 
         * Constructor that provides a connection upon which to act
 
239
         * Constructor that provides a connection upon which to act.
 
240
         *
236
241
         * @param connection a connection
237
242
         */
238
243
        explicit transaction_guard(
255
260
public:
256
261
 
257
262
        /**
258
 
         * Commit the transaction
 
263
         * Commit the transaction.
259
264
         */
260
265
        void commit()
261
266
        {
266
271
        }
267
272
 
268
273
        /**
269
 
         * Rollback the transaction early
 
274
         * Rollback the transaction early.
270
275
         */
271
276
        void rollback()
272
277
        {