# HG changeset patch # User Sebastien Jodogne # Date 1448643376 -3600 # Node ID fbc5522023aa2faeaf250b9c9adddc7ce3546f1e # Parent 2faa2abbf3118359c68c9f7cd9d50fa9b77ae07c refactoring diff -r 2faa2abbf311 -r fbc5522023aa Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp --- a/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Fri Nov 27 17:40:25 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Fri Nov 27 17:56:16 2015 +0100 @@ -60,10 +60,10 @@ } - OrthancPluginImage* GdcmDecoderCache::Decode(OrthancPluginContext* context, - const void* dicom, - const uint32_t size, - uint32_t frameIndex) + OrthancImageWrapper* GdcmDecoderCache::Decode(OrthancPluginContext* context, + const void* dicom, + const uint32_t size, + uint32_t frameIndex) { std::string md5 = ComputeMd5(context, dicom, size); @@ -77,13 +77,13 @@ md5_ == md5) { // This is the same image: Reuse the previous decoding - return decoder_->Decode(context, frameIndex); + return new OrthancImageWrapper(context, *decoder_, frameIndex); } } // This is not the same image std::auto_ptr decoder(new GdcmImageDecoder(dicom, size)); - OrthancImageWrapper image(context, *decoder, frameIndex); + std::auto_ptr image(new OrthancImageWrapper(context, *decoder, frameIndex)); { // Cache the newly created decoder for further use @@ -93,6 +93,6 @@ md5_ = md5; } - return image.Release(); + return image.release(); } } diff -r 2faa2abbf311 -r fbc5522023aa Plugins/Samples/GdcmDecoder/GdcmDecoderCache.h --- a/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.h Fri Nov 27 17:40:25 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.h Fri Nov 27 17:56:16 2015 +0100 @@ -21,6 +21,7 @@ #pragma once #include "GdcmImageDecoder.h" +#include "OrthancImageWrapper.h" #include @@ -44,9 +45,9 @@ { } - OrthancPluginImage* Decode(OrthancPluginContext* context, - const void* dicom, - const uint32_t size, - uint32_t frameIndex); + OrthancImageWrapper* Decode(OrthancPluginContext* context, + const void* dicom, + const uint32_t size, + uint32_t frameIndex); }; } diff -r 2faa2abbf311 -r fbc5522023aa Plugins/Samples/GdcmDecoder/Plugin.cpp --- a/Plugins/Samples/GdcmDecoder/Plugin.cpp Fri Nov 27 17:40:25 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/Plugin.cpp Fri Nov 27 17:56:16 2015 +0100 @@ -19,6 +19,7 @@ #include "GdcmDecoderCache.h" +#include "OrthancImageWrapper.h" #include @@ -33,14 +34,18 @@ { try { + std::auto_ptr image; + #if 0 // Do not use the cache OrthancPlugins::GdcmImageDecoder decoder(dicom, size); - *target = decoder.Decode(context_, frameIndex); + image.reset(new OrthancPlugins::OrthancImageWrapper(context_, decoder, frameIndex)); #else - *target = cache_.Decode(context_, dicom, size, frameIndex); + image.reset(cache_.Decode(context_, dicom, size, frameIndex)); #endif + *target = image->Release(); + return OrthancPluginErrorCode_Success; } catch (std::runtime_error& e)