comparison Plugin/Plugin.cpp @ 102:21123729ac71 refactoring

simplification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Nov 2015 11:02:50 +0100
parents f5b1a9267da0
children 628697fdfcbd
comparison
equal deleted inserted replaced
101:2932473a9b19 102:21123729ac71
26 #include "../Orthanc/Core/OrthancException.h" 26 #include "../Orthanc/Core/OrthancException.h"
27 #include "ViewerToolbox.h" 27 #include "ViewerToolbox.h"
28 #include "ViewerPrefetchPolicy.h" 28 #include "ViewerPrefetchPolicy.h"
29 #include "DecodedImageAdapter.h" 29 #include "DecodedImageAdapter.h"
30 #include "SeriesInformationAdapter.h" 30 #include "SeriesInformationAdapter.h"
31 #include "../Orthanc/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h" 31 #include "../Orthanc/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.h"
32 #include "../Orthanc/Core/Toolbox.h" 32 #include "../Orthanc/Core/Toolbox.h"
33 33
34 34
35 static OrthancPluginContext* context_ = NULL; 35 static OrthancPluginContext* context_ = NULL;
36 36
62 std::auto_ptr<OrthancPlugins::CacheScheduler> scheduler_; 62 std::auto_ptr<OrthancPlugins::CacheScheduler> scheduler_;
63 63
64 Orthanc::SharedMessageQueue newInstances_; 64 Orthanc::SharedMessageQueue newInstances_;
65 bool stop_; 65 bool stop_;
66 boost::thread newInstancesThread_; 66 boost::thread newInstancesThread_;
67 67 OrthancPlugins::GdcmDecoderCache decoder_;
68 68
69 static void NewInstancesThread(CacheContext* cache) 69 static void NewInstancesThread(CacheContext* cache)
70 { 70 {
71 while (!cache->stop_) 71 while (!cache->stop_)
72 { 72 {
121 121
122 void SignalNewInstance(const char* instanceId) 122 void SignalNewInstance(const char* instanceId)
123 { 123 {
124 newInstances_.Enqueue(new DynamicString(instanceId)); 124 newInstances_.Enqueue(new DynamicString(instanceId));
125 } 125 }
126
127 OrthancPlugins::GdcmDecoderCache& GetDecoder()
128 {
129 return decoder_;
130 }
126 }; 131 };
127 132
128 133
129 134
130 static CacheContext* cache_ = NULL; 135 static CacheContext* cache_ = NULL;
331 // Do not use the cache 336 // Do not use the cache
332 OrthancPlugins::GdcmImageDecoder decoder(dicom, size); 337 OrthancPlugins::GdcmImageDecoder decoder(dicom, size);
333 image.reset(new OrthancPlugins::OrthancImageWrapper(context_, decoder, frameIndex)); 338 image.reset(new OrthancPlugins::OrthancImageWrapper(context_, decoder, frameIndex));
334 #else 339 #else
335 using namespace OrthancPlugins; 340 using namespace OrthancPlugins;
336 ICacheFactory& factory = cache_->GetScheduler().GetFactory(CacheBundle_DecodedImage); 341 image.reset(cache_->GetDecoder().Decode(context_, dicom, size, frameIndex));
337 image.reset(dynamic_cast<DecodedImageAdapter&>(factory).GetDecoderCache().Decode(context_, dicom, size, frameIndex));
338 #endif 342 #endif
339 343
340 *target = image->Release(); 344 *target = image->Release();
341 345
342 return OrthancPluginErrorCode_Success; 346 return OrthancPluginErrorCode_Success;