Mercurial > hg > orthanc
comparison Core/SQLite/Transaction.cpp @ 50:a15e90e5d6fc
rename in code
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Sep 2012 15:50:12 +0200 |
parents | db4d996ea264 |
children | c996319e90bc |
comparison
equal
deleted
inserted
replaced
49:e1a3ae0dadf3 | 50:a15e90e5d6fc |
---|---|
1 /** | 1 /** |
2 * Palantir - A Lightweight, RESTful DICOM Store | 2 * Palanthir - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, | 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, |
4 * Belgium | 4 * Belgium |
5 * | 5 * |
6 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 6 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
7 * | 7 * |
34 **/ | 34 **/ |
35 | 35 |
36 | 36 |
37 #include "Transaction.h" | 37 #include "Transaction.h" |
38 | 38 |
39 namespace Palantir | 39 namespace Palanthir |
40 { | 40 { |
41 namespace SQLite | 41 namespace SQLite |
42 { | 42 { |
43 Transaction::Transaction(Connection& connection) : | 43 Transaction::Transaction(Connection& connection) : |
44 connection_(connection), | 44 connection_(connection), |
56 | 56 |
57 void Transaction::Begin() | 57 void Transaction::Begin() |
58 { | 58 { |
59 if (isOpen_) | 59 if (isOpen_) |
60 { | 60 { |
61 throw PalantirException("SQLite: Beginning a transaction twice!"); | 61 throw PalanthirException("SQLite: Beginning a transaction twice!"); |
62 } | 62 } |
63 | 63 |
64 isOpen_ = connection_.BeginTransaction(); | 64 isOpen_ = connection_.BeginTransaction(); |
65 if (!isOpen_) | 65 if (!isOpen_) |
66 { | 66 { |
67 throw PalantirException("SQLite: Unable to create a transaction"); | 67 throw PalanthirException("SQLite: Unable to create a transaction"); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 void Transaction::Rollback() | 71 void Transaction::Rollback() |
72 { | 72 { |
73 if (!isOpen_) | 73 if (!isOpen_) |
74 { | 74 { |
75 throw PalantirException("SQLite: Attempting to roll back a nonexistent transaction. " | 75 throw PalanthirException("SQLite: Attempting to roll back a nonexistent transaction. " |
76 "Did you remember to call Begin()?"); | 76 "Did you remember to call Begin()?"); |
77 } | 77 } |
78 | 78 |
79 isOpen_ = false; | 79 isOpen_ = false; |
80 | 80 |
83 | 83 |
84 void Transaction::Commit() | 84 void Transaction::Commit() |
85 { | 85 { |
86 if (!isOpen_) | 86 if (!isOpen_) |
87 { | 87 { |
88 throw PalantirException("SQLite: Attempting to roll back a nonexistent transaction. " | 88 throw PalanthirException("SQLite: Attempting to roll back a nonexistent transaction. " |
89 "Did you remember to call Begin()?"); | 89 "Did you remember to call Begin()?"); |
90 } | 90 } |
91 | 91 |
92 isOpen_ = false; | 92 isOpen_ = false; |
93 | 93 |
94 if (!connection_.CommitTransaction()) | 94 if (!connection_.CommitTransaction()) |
95 { | 95 { |
96 throw PalantirException("SQLite: Failure when committing the transaction"); | 96 throw PalanthirException("SQLite: Failure when committing the transaction"); |
97 } | 97 } |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |