diff Plugin/Plugin.cpp @ 96:a6ba21a083e5 refactoring

major refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Nov 2015 18:26:55 +0100
parents dbe7c97b6b4a
children 46ec13a1177c
line wrap: on
line diff
--- a/Plugin/Plugin.cpp	Fri Nov 27 16:19:09 2015 +0100
+++ b/Plugin/Plugin.cpp	Fri Nov 27 18:26:55 2015 +0100
@@ -327,14 +327,20 @@
 {
   try
   {
-#if 1
+    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);
+    using namespace OrthancPlugins;
+    ICacheFactory& factory = cache_->GetScheduler().GetFactory(CacheBundle_DecodedImage);
+    image.reset(dynamic_cast<DecodedImageAdapter&>(factory).GetDecoderCache().Decode(context_, dicom, size, frameIndex));
 #endif
 
+    *target = image->Release();
+
     return OrthancPluginErrorCode_Success;
   }
   catch (std::runtime_error& e)