Mercurial > hg > orthanc
changeset 1837:fbc5522023aa
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 27 Nov 2015 17:56:16 +0100 |
parents | 2faa2abbf311 |
children | 2137df64a64c |
files | Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Plugins/Samples/GdcmDecoder/GdcmDecoderCache.h Plugins/Samples/GdcmDecoder/Plugin.cpp |
diffstat | 3 files changed, 19 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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<GdcmImageDecoder> decoder(new GdcmImageDecoder(dicom, size)); - OrthancImageWrapper image(context, *decoder, frameIndex); + std::auto_ptr<OrthancImageWrapper> 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(); } }
--- 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 <boost/thread.hpp> @@ -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); }; }
--- 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 <orthanc/OrthancCPlugin.h> @@ -33,14 +34,18 @@ { try { + std::auto_ptr<OrthancPlugins::OrthancImageWrapper> 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)