comparison Core/SQLite/Transaction.h @ 1235:9b4977e3c19d

abstraction
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Dec 2014 14:31:46 +0100
parents 2255e66da726
children 63d47b1fa239
comparison
equal deleted inserted replaced
1234:a65ad39596cb 1235:9b4977e3c19d
36 36
37 37
38 #pragma once 38 #pragma once
39 39
40 #include "Connection.h" 40 #include "Connection.h"
41 #include "ITransaction.h"
41 42
42 namespace Orthanc 43 namespace Orthanc
43 { 44 {
44 namespace SQLite 45 namespace SQLite
45 { 46 {
46 class Transaction : public NonCopyable 47 class Transaction : public ITransaction
47 { 48 {
48 private: 49 private:
49 Connection& connection_; 50 Connection& connection_;
50 51
51 // True when the transaction is open, false when it's already been committed 52 // True when the transaction is open, false when it's already been committed
52 // or rolled back. 53 // or rolled back.
53 bool isOpen_; 54 bool isOpen_;
54 55
55 public: 56 public:
56 explicit Transaction(Connection& connection); 57 explicit Transaction(Connection& connection);
57 ~Transaction(); 58
59 virtual ~Transaction();
58 60
59 // Returns true when there is a transaction that has been successfully begun. 61 // Returns true when there is a transaction that has been successfully begun.
60 bool IsOpen() const { return isOpen_; } 62 bool IsOpen() const { return isOpen_; }
61 63
62 // Begins the transaction. This uses the default sqlite "deferred" transaction 64 virtual void Begin();
63 // type, which means that the DB lock is lazily acquired the next time the
64 // database is accessed, not in the begin transaction command.
65 void Begin();
66 65
67 // Rolls back the transaction. This will happen automatically if you do 66 virtual void Rollback();
68 // nothing when the transaction goes out of scope.
69 void Rollback();
70 67
71 // Commits the transaction, returning true on success. 68 virtual void Commit();
72 void Commit();
73 }; 69 };
74 } 70 }
75 } 71 }