Mercurial > hg > orthanc-databases
diff Framework/Common/DatabaseManager.cpp @ 241:a063bbf10a3e
simplification of class DatabaseManager::Transaction
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 13 Apr 2021 12:07:30 +0200 |
parents | f2b32d31fc99 |
children | b97a537f4613 |
line wrap: on
line diff
--- a/Framework/Common/DatabaseManager.cpp Mon Apr 12 17:07:06 2021 +0200 +++ b/Framework/Common/DatabaseManager.cpp Tue Apr 13 12:07:30 2021 +0200 @@ -241,7 +241,7 @@ TransactionType type) : manager_(manager), database_(manager.GetDatabase()), - committed_(false) + active_(true) { manager_.StartTransaction(type); } @@ -249,7 +249,7 @@ DatabaseManager::Transaction::~Transaction() { - if (!committed_) + if (active_) { try { @@ -266,14 +266,28 @@ void DatabaseManager::Transaction::Commit() { - if (committed_) + if (active_) + { + manager_.CommitTransaction(); + active_ = true; + } + else { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } + } + + + void DatabaseManager::Transaction::Rollback() + { + if (active_) + { + manager_.RollbackTransaction(); + active_ = true; + } else { - manager_.CommitTransaction(); - committed_ = true; + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } }