Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp @ 5455:176bc05f85f4 pg-transactions
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 07 Dec 2023 12:04:11 +0100 |
parents | f22c8fac764b |
children | dceed5e3d6a9 |
comparison
equal
deleted
inserted
replaced
5454:099d45f49fe1 | 5455:176bc05f85f4 |
---|---|
43 ErrorCode_DatabasePlugin, "Missing primitive: " #func "()"); \ | 43 ErrorCode_DatabasePlugin, "Missing primitive: " #func "()"); \ |
44 } | 44 } |
45 | 45 |
46 namespace Orthanc | 46 namespace Orthanc |
47 { | 47 { |
48 class OrthancPluginDatabaseV3::Transaction : public IDatabaseWrapper::ITransaction | 48 class OrthancPluginDatabaseV3::Transaction : public BaseDatabaseWrapper::BaseTransaction |
49 { | 49 { |
50 private: | 50 private: |
51 OrthancPluginDatabaseV3& that_; | 51 OrthancPluginDatabaseV3& that_; |
52 IDatabaseListener& listener_; | 52 IDatabaseListener& listener_; |
53 OrthancPluginDatabaseTransaction* transaction_; | 53 OrthancPluginDatabaseTransaction* transaction_; |
276 // Don't throw exception in destructors | 276 // Don't throw exception in destructors |
277 that_.errorDictionary_.LogError(code, true); | 277 that_.errorDictionary_.LogError(code, true); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 virtual const IDatabaseWrapper::Capabilities& GetDatabaseCapabilities() const ORTHANC_OVERRIDE | |
282 { | |
283 return that_.GetDatabaseCapabilities(); | |
284 } | |
281 | 285 |
282 virtual void Rollback() ORTHANC_OVERRIDE | 286 virtual void Rollback() ORTHANC_OVERRIDE |
283 { | 287 { |
284 CheckSuccess(that_.backend_.rollback(transaction_)); | 288 CheckSuccess(that_.backend_.rollback(transaction_)); |
285 CheckNoEvent(); | 289 CheckNoEvent(); |
1081 void* database, | 1085 void* database, |
1082 const std::string& serverIdentifier) : | 1086 const std::string& serverIdentifier) : |
1083 library_(library), | 1087 library_(library), |
1084 errorDictionary_(errorDictionary), | 1088 errorDictionary_(errorDictionary), |
1085 database_(database), | 1089 database_(database), |
1086 serverIdentifier_(serverIdentifier) | 1090 serverIdentifier_(serverIdentifier), |
1091 dbCapabilities_(false, false /* revision support is updated in open() */, false, false) | |
1087 { | 1092 { |
1088 CLOG(INFO, PLUGINS) << "Identifier of this Orthanc server for the global properties " | 1093 CLOG(INFO, PLUGINS) << "Identifier of this Orthanc server for the global properties " |
1089 << "of the custom database: \"" << serverIdentifier << "\""; | 1094 << "of the custom database: \"" << serverIdentifier << "\""; |
1090 | 1095 |
1091 if (backendSize >= sizeof(backend_)) | 1096 if (backendSize >= sizeof(backend_)) |
1188 | 1193 |
1189 | 1194 |
1190 void OrthancPluginDatabaseV3::Open() | 1195 void OrthancPluginDatabaseV3::Open() |
1191 { | 1196 { |
1192 CheckSuccess(backend_.open(database_)); | 1197 CheckSuccess(backend_.open(database_)); |
1198 | |
1199 // update the db capabilities | |
1200 uint8_t hasRevisions; | |
1201 CheckSuccess(backend_.hasRevisionsSupport(database_, &hasRevisions)); | |
1202 dbCapabilities_.hasRevisionsSupport_ = (hasRevisions != 0); | |
1193 } | 1203 } |
1194 | 1204 |
1195 | 1205 |
1196 void OrthancPluginDatabaseV3::Close() | 1206 void OrthancPluginDatabaseV3::Close() |
1197 { | 1207 { |
1248 throw OrthancException(static_cast<ErrorCode>(code)); | 1258 throw OrthancException(static_cast<ErrorCode>(code)); |
1249 } | 1259 } |
1250 } | 1260 } |
1251 } | 1261 } |
1252 | 1262 |
1253 | |
1254 bool OrthancPluginDatabaseV3::HasRevisionsSupport() const | |
1255 { | |
1256 // WARNING: This method requires "Open()" to have been called | |
1257 uint8_t hasRevisions; | |
1258 CheckSuccess(backend_.hasRevisionsSupport(database_, &hasRevisions)); | |
1259 return (hasRevisions != 0); | |
1260 } | |
1261 } | 1263 } |