comparison Framework/Deprecated/SmartLoader.cpp @ 1298:8a0a62189f46

replacing std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Mar 2020 16:31:30 +0100
parents 2d8ab34c8c91
children 257f2c9a02ac
comparison
equal deleted inserted replaced
1296:86400fa16091 1298:8a0a62189f46
60 return FrameRenderer::CreateRenderer(*that_.image_, *that_.slice_, isFull); 60 return FrameRenderer::CreateRenderer(*that_.image_, *that_.slice_, isFull);
61 } 61 }
62 }; 62 };
63 63
64 unsigned int sliceIndex_; 64 unsigned int sliceIndex_;
65 std::auto_ptr<Slice> slice_; 65 std::unique_ptr<Slice> slice_;
66 boost::shared_ptr<Orthanc::ImageAccessor> image_; 66 boost::shared_ptr<Orthanc::ImageAccessor> image_;
67 SliceImageQuality effectiveQuality_; 67 SliceImageQuality effectiveQuality_;
68 CachedSliceStatus status_; 68 CachedSliceStatus status_;
69 69
70 public: 70 public:
138 // (it can not be immediate because Observers needs to register first and this is done after this method returns) 138 // (it can not be immediate because Observers needs to register first and this is done after this method returns)
139 // - if currently loading, we need to return an object that will observe the existing VolumeSlicer and forward 139 // - if currently loading, we need to return an object that will observe the existing VolumeSlicer and forward
140 // the messages to its observables 140 // the messages to its observables
141 // in both cases, we must be carefull about objects lifecycle !!! 141 // in both cases, we must be carefull about objects lifecycle !!!
142 142
143 std::auto_ptr<IVolumeSlicer> layerSource; 143 std::unique_ptr<IVolumeSlicer> layerSource;
144 std::string sliceKeyId = instanceId + ":" + boost::lexical_cast<std::string>(frame); 144 std::string sliceKeyId = instanceId + ":" + boost::lexical_cast<std::string>(frame);
145 SmartLoader::CachedSlice* cachedSlice = NULL; 145 SmartLoader::CachedSlice* cachedSlice = NULL;
146 146
147 if (cachedSlices_.find(sliceKeyId) != cachedSlices_.end()) // && cachedSlices_[sliceKeyId]->status_ == CachedSliceStatus_Loaded) 147 if (cachedSlices_.find(sliceKeyId) != cachedSlices_.end()) // && cachedSlices_[sliceKeyId]->status_ == CachedSliceStatus_Loaded)
148 { 148 {
197 197
198 LOG(WARNING) << "Will preload: " << sliceKeyId; 198 LOG(WARNING) << "Will preload: " << sliceKeyId;
199 199
200 cachedSlices_[sliceKeyId] = boost::shared_ptr<CachedSlice>(cachedSlice); 200 cachedSlices_[sliceKeyId] = boost::shared_ptr<CachedSlice>(cachedSlice);
201 201
202 std::auto_ptr<IVolumeSlicer> layerSource(new DicomSeriesVolumeSlicer(IObserver::GetBroker(), orthancApiClient_)); 202 std::unique_ptr<IVolumeSlicer> layerSource(new DicomSeriesVolumeSlicer(IObserver::GetBroker(), orthancApiClient_));
203 203
204 dynamic_cast<DicomSeriesVolumeSlicer*>(layerSource.get())->SetImageQuality(imageQuality_); 204 dynamic_cast<DicomSeriesVolumeSlicer*>(layerSource.get())->SetImageQuality(imageQuality_);
205 layerSource->RegisterObserverCallback(new OrthancStone::Callable<SmartLoader, IVolumeSlicer::GeometryReadyMessage>(*this, &SmartLoader::OnLayerGeometryReady)); 205 layerSource->RegisterObserverCallback(new OrthancStone::Callable<SmartLoader, IVolumeSlicer::GeometryReadyMessage>(*this, &SmartLoader::OnLayerGeometryReady));
206 layerSource->RegisterObserverCallback(new OrthancStone::Callable<SmartLoader, DicomSeriesVolumeSlicer::FrameReadyMessage>(*this, &SmartLoader::OnFrameReady)); 206 layerSource->RegisterObserverCallback(new OrthancStone::Callable<SmartLoader, DicomSeriesVolumeSlicer::FrameReadyMessage>(*this, &SmartLoader::OnFrameReady));
207 layerSource->RegisterObserverCallback(new OrthancStone::Callable<SmartLoader, IVolumeSlicer::LayerReadyMessage>(*this, &SmartLoader::OnLayerReady)); 207 layerSource->RegisterObserverCallback(new OrthancStone::Callable<SmartLoader, IVolumeSlicer::LayerReadyMessage>(*this, &SmartLoader::OnLayerReady));