comparison Framework/OrthancInstancesCache.cpp @ 25:dfc43678aecb

replacing deprecated std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 06 Jul 2020 16:25:56 +0200
parents b06103a50c95
children 44a0430d7899
comparison
equal deleted inserted replaced
24:065bc476bcdc 25:dfc43678aecb
17 **/ 17 **/
18 18
19 19
20 #include "OrthancInstancesCache.h" 20 #include "OrthancInstancesCache.h"
21 21
22 #include <Compatibility.h> // For std::unique_ptr
22 23
23 namespace OrthancPlugins 24 namespace OrthancPlugins
24 { 25 {
25 void OrthancInstancesCache::CacheAccessor::CheckValid() const 26 void OrthancInstancesCache::CacheAccessor::CheckValid() const
26 { 27 {
117 content_.erase(instance); 118 content_.erase(instance);
118 } 119 }
119 120
120 121
121 void OrthancInstancesCache::Store(const std::string& instanceId, 122 void OrthancInstancesCache::Store(const std::string& instanceId,
122 std::auto_ptr<SourceDicomInstance>& instance) 123 std::unique_ptr<SourceDicomInstance>& instance)
123 { 124 {
124 if (instance.get() == NULL) 125 if (instance.get() == NULL)
125 { 126 {
126 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); 127 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
127 } 128 }
220 return; 221 return;
221 } 222 }
222 } 223 }
223 224
224 // The instance was not in the cache, load it 225 // The instance was not in the cache, load it
225 std::auto_ptr<SourceDicomInstance> instance(new SourceDicomInstance(instanceId)); 226 std::unique_ptr<SourceDicomInstance> instance(new SourceDicomInstance(instanceId));
226 size = instance->GetInfo().GetSize(); 227 size = instance->GetInfo().GetSize();
227 md5 = instance->GetInfo().GetMD5(); 228 md5 = instance->GetInfo().GetMD5();
228 229
229 // Store the just-loaded DICOM instance into the cache 230 // Store the just-loaded DICOM instance into the cache
230 { 231 {
249 return; 250 return;
250 } 251 }
251 } 252 }
252 253
253 // The instance was not in the cache, load it 254 // The instance was not in the cache, load it
254 std::auto_ptr<SourceDicomInstance> instance(new SourceDicomInstance(instanceId)); 255 std::unique_ptr<SourceDicomInstance> instance(new SourceDicomInstance(instanceId));
255 instance->GetChunk(chunk, md5, 0, instance->GetInfo().GetSize()); 256 instance->GetChunk(chunk, md5, 0, instance->GetInfo().GetSize());
256 257
257 // Store the just-loaded DICOM instance into the cache 258 // Store the just-loaded DICOM instance into the cache
258 { 259 {
259 boost::mutex::scoped_lock lock(mutex_); 260 boost::mutex::scoped_lock lock(mutex_);