Mercurial > hg > orthanc-databases
comparison Framework/Common/DatabaseManager.h @ 241:a063bbf10a3e
simplification of class DatabaseManager::Transaction
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 13 Apr 2021 12:07:30 +0200 |
parents | 35598014f140 |
children | 8a4ce70f456a |
comparison
equal
deleted
inserted
replaced
240:c82c2cf84ae8 | 241:a063bbf10a3e |
---|---|
86 void CommitTransaction(); | 86 void CommitTransaction(); |
87 | 87 |
88 void RollbackTransaction(); | 88 void RollbackTransaction(); |
89 | 89 |
90 | 90 |
91 // This class is only used in the "StorageBackend" | 91 // This class is only used in the "StorageBackend" and in |
92 // "IDatabaseBackend::ConfigureDatabase()" | |
92 class Transaction : public boost::noncopyable | 93 class Transaction : public boost::noncopyable |
93 { | 94 { |
94 private: | 95 private: |
95 DatabaseManager& manager_; | 96 DatabaseManager& manager_; |
96 IDatabase& database_; | 97 IDatabase& database_; |
97 bool committed_; | 98 bool active_; |
98 | 99 |
99 public: | 100 public: |
100 explicit Transaction(DatabaseManager& manager, | 101 explicit Transaction(DatabaseManager& manager, |
101 TransactionType type); | 102 TransactionType type); |
102 | 103 |
103 ~Transaction(); | 104 ~Transaction(); |
104 | 105 |
105 void Commit(); | 106 void Commit(); |
106 | 107 |
107 DatabaseManager& GetManager() | 108 void Rollback(); |
108 { | 109 |
109 return manager_; | 110 /** |
110 } | 111 * WARNING: Don't call "GetDatabaseTransaction().Commit()" and |
111 | 112 * "GetDatabaseTransaction().Rollback()", but use the "Commit()" |
112 IDatabase& GetDatabase() | 113 * and "Rollback()" methods above. |
113 { | 114 **/ |
114 return database_; | 115 ITransaction& GetDatabaseTransaction() |
115 } | 116 { |
116 | 117 return manager_.GetTransaction(); |
117 bool DoesTableExist(const std::string& name) | |
118 { | |
119 return manager_.GetTransaction().DoesTableExist(name); | |
120 } | |
121 | |
122 bool DoesTriggerExist(const std::string& name) | |
123 { | |
124 return manager_.GetTransaction().DoesTriggerExist(name); | |
125 } | |
126 | |
127 void ExecuteMultiLines(const std::string& sql) | |
128 { | |
129 manager_.GetTransaction().ExecuteMultiLines(sql); | |
130 } | 118 } |
131 }; | 119 }; |
132 | 120 |
133 | 121 |
134 class StatementBase : public boost::noncopyable | 122 class StatementBase : public boost::noncopyable |