Mercurial > hg > orthanc-databases
diff Framework/Plugins/StorageBackend.cpp @ 195:53bd9022c58b
Support of "OrthancPluginRegisterStorageArea2()" from Orthanc SDK 1.9.0
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 08 Jan 2021 18:54:20 +0100 |
parents | a51ce147dbe0 |
children | d9ef3f16e6a2 |
line wrap: on
line diff
--- a/Framework/Plugins/StorageBackend.cpp Fri Jan 08 14:40:03 2021 +0100 +++ b/Framework/Plugins/StorageBackend.cpp Fri Jan 08 18:54:20 2021 +0100 @@ -170,6 +170,28 @@ } +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 0) + static OrthancPluginErrorCode StorageReadWhole(OrthancPluginMemoryBuffer64 *target, + const char* uuid, + OrthancPluginContentType type) + { + try + { + StorageAreaBuffer buffer(context_); + + { + DatabaseManager::Transaction transaction(backend_->GetManager()); + backend_->Read(buffer, transaction, uuid, type); + transaction.Commit(); + } + + buffer.Move(target); + + return OrthancPluginErrorCode_Success; + } + ORTHANC_PLUGINS_DATABASE_CATCH; + } +#else static OrthancPluginErrorCode StorageRead(void** content, int64_t* size, const char* uuid, @@ -177,7 +199,7 @@ { try { - StorageAreaBuffer buffer; + StorageAreaBuffer buffer(context_); { DatabaseManager::Transaction transaction(backend_->GetManager()); @@ -192,6 +214,7 @@ } ORTHANC_PLUGINS_DATABASE_CATCH; } +#endif static OrthancPluginErrorCode StorageRemove(const char* uuid, @@ -229,7 +252,12 @@ backend_.reset(backend); backend_->GetManager().Open(); +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 0) + OrthancPluginRegisterStorageArea2(context_, StorageCreate, StorageReadWhole, + NULL /* TODO - StorageReadRange */, StorageRemove); +#else OrthancPluginRegisterStorageArea(context_, StorageCreate, StorageRead, StorageRemove); +#endif } }