Mercurial > hg > orthanc-stone
comparison Framework/Loaders/SeriesThumbnailsLoader.cpp @ 1299:c38c89684d83 broker
replacing std::auto_ptr by std::unique_ptr
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 02 Mar 2020 17:21:24 +0100 |
parents | 0ca50d275b9a |
children | 30deba7bc8e2 |
comparison
equal
deleted
inserted
replaced
1297:6ab03e429f06 | 1299:c38c89684d83 |
---|---|
76 const std::string& seriesInstanceUid, | 76 const std::string& seriesInstanceUid, |
77 SeriesThumbnailsLoader::Thumbnail* thumbnail) | 77 SeriesThumbnailsLoader::Thumbnail* thumbnail) |
78 { | 78 { |
79 assert(thumbnail != NULL); | 79 assert(thumbnail != NULL); |
80 | 80 |
81 std::auto_ptr<Thumbnail> protection(thumbnail); | 81 std::unique_ptr<Thumbnail> protection(thumbnail); |
82 | 82 |
83 Thumbnails::iterator found = thumbnails_.find(seriesInstanceUid); | 83 Thumbnails::iterator found = thumbnails_.find(seriesInstanceUid); |
84 if (found == thumbnails_.end()) | 84 if (found == thumbnails_.end()) |
85 { | 85 { |
86 thumbnails_[seriesInstanceUid] = protection.release(); | 86 thumbnails_[seriesInstanceUid] = protection.release(); |
252 std::map<std::string, std::string> arguments, headers; | 252 std::map<std::string, std::string> arguments, headers; |
253 arguments["0020000D"] = GetStudyInstanceUid(); | 253 arguments["0020000D"] = GetStudyInstanceUid(); |
254 arguments["0020000E"] = GetSeriesInstanceUid(); | 254 arguments["0020000E"] = GetSeriesInstanceUid(); |
255 arguments["includefield"] = "00080016"; | 255 arguments["includefield"] = "00080016"; |
256 | 256 |
257 std::auto_ptr<IOracleCommand> command( | 257 std::unique_ptr<IOracleCommand> command( |
258 GetSource().CreateDicomWebCommand( | 258 GetSource().CreateDicomWebCommand( |
259 "/instances", arguments, headers, new DicomWebSopClassHandler( | 259 "/instances", arguments, headers, new DicomWebSopClassHandler( |
260 GetLoader(), GetSource(), GetStudyInstanceUid(), GetSeriesInstanceUid()))); | 260 GetLoader(), GetSource(), GetStudyInstanceUid(), GetSeriesInstanceUid()))); |
261 GetLoader()->Schedule(command.release()); | 261 GetLoader()->Schedule(command.release()); |
262 } | 262 } |
324 GetLoader()->AcquireThumbnail(GetSource(), GetStudyInstanceUid(), | 324 GetLoader()->AcquireThumbnail(GetSource(), GetStudyInstanceUid(), |
325 GetSeriesInstanceUid(), new Thumbnail(type)); | 325 GetSeriesInstanceUid(), new Thumbnail(type)); |
326 } | 326 } |
327 else | 327 else |
328 { | 328 { |
329 std::auto_ptr<GetOrthancImageCommand> command(new GetOrthancImageCommand); | 329 std::unique_ptr<GetOrthancImageCommand> command(new GetOrthancImageCommand); |
330 command->SetUri("/instances/" + instanceId_ + "/preview"); | 330 command->SetUri("/instances/" + instanceId_ + "/preview"); |
331 command->SetHttpHeader("Accept", Orthanc::MIME_JPEG); | 331 command->SetHttpHeader("Accept", Orthanc::MIME_JPEG); |
332 command->AcquirePayload(new ThumbnailInformation( | 332 command->AcquirePayload(new ThumbnailInformation( |
333 GetSource(), GetStudyInstanceUid(), GetSeriesInstanceUid())); | 333 GetSource(), GetStudyInstanceUid(), GetSeriesInstanceUid())); |
334 GetLoader()->Schedule(command.release()); | 334 GetLoader()->Schedule(command.release()); |
373 arguments["quality"] = boost::lexical_cast<std::string>(JPEG_QUALITY); | 373 arguments["quality"] = boost::lexical_cast<std::string>(JPEG_QUALITY); |
374 headers["Accept"] = Orthanc::MIME_JPEG; | 374 headers["Accept"] = Orthanc::MIME_JPEG; |
375 | 375 |
376 const std::string instance = json[INSTANCES][index].asString(); | 376 const std::string instance = json[INSTANCES][index].asString(); |
377 | 377 |
378 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); | 378 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
379 command->SetUri("/instances/" + instance + "/metadata/SopClassUid"); | 379 command->SetUri("/instances/" + instance + "/metadata/SopClassUid"); |
380 command->AcquirePayload( | 380 command->AcquirePayload( |
381 new OrthancSopClassHandler( | 381 new OrthancSopClassHandler( |
382 GetLoader(), GetSource(), GetStudyInstanceUid(), GetSeriesInstanceUid(), instance)); | 382 GetLoader(), GetSource(), GetStudyInstanceUid(), GetSeriesInstanceUid(), instance)); |
383 GetLoader()->Schedule(command.release()); | 383 GetLoader()->Schedule(command.release()); |
387 }; | 387 }; |
388 | 388 |
389 | 389 |
390 void SeriesThumbnailsLoader::Schedule(IOracleCommand* command) | 390 void SeriesThumbnailsLoader::Schedule(IOracleCommand* command) |
391 { | 391 { |
392 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); | 392 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
393 lock->Schedule(GetSharedObserver(), priority_, command); | 393 lock->Schedule(GetSharedObserver(), priority_, command); |
394 } | 394 } |
395 | 395 |
396 | 396 |
397 void SeriesThumbnailsLoader::Handle(const HttpCommand::SuccessMessage& message) | 397 void SeriesThumbnailsLoader::Handle(const HttpCommand::SuccessMessage& message) |
410 | 410 |
411 void SeriesThumbnailsLoader::Handle(const GetOrthancImageCommand::SuccessMessage& message) | 411 void SeriesThumbnailsLoader::Handle(const GetOrthancImageCommand::SuccessMessage& message) |
412 { | 412 { |
413 assert(message.GetOrigin().HasPayload()); | 413 assert(message.GetOrigin().HasPayload()); |
414 | 414 |
415 std::auto_ptr<Orthanc::ImageAccessor> resized(Orthanc::ImageProcessing::FitSize(message.GetImage(), width_, height_)); | 415 std::unique_ptr<Orthanc::ImageAccessor> resized(Orthanc::ImageProcessing::FitSize(message.GetImage(), width_, height_)); |
416 | 416 |
417 std::string jpeg; | 417 std::string jpeg; |
418 Orthanc::JpegWriter writer; | 418 Orthanc::JpegWriter writer; |
419 writer.SetQuality(JPEG_QUALITY); | 419 writer.SetQuality(JPEG_QUALITY); |
420 writer.WriteToMemory(jpeg, *resized); | 420 writer.WriteToMemory(jpeg, *resized); |
538 // Needed to set this header explicitly, as long as emscripten | 538 // Needed to set this header explicitly, as long as emscripten |
539 // does not include macro "EMSCRIPTEN_FETCH_RESPONSE_HEADERS" | 539 // does not include macro "EMSCRIPTEN_FETCH_RESPONSE_HEADERS" |
540 // https://github.com/emscripten-core/emscripten/pull/8486 | 540 // https://github.com/emscripten-core/emscripten/pull/8486 |
541 headers["Accept"] = Orthanc::MIME_JPEG; | 541 headers["Accept"] = Orthanc::MIME_JPEG; |
542 | 542 |
543 std::auto_ptr<IOracleCommand> command( | 543 std::unique_ptr<IOracleCommand> command( |
544 source.CreateDicomWebCommand( | 544 source.CreateDicomWebCommand( |
545 uri, arguments, headers, new DicomWebThumbnailHandler( | 545 uri, arguments, headers, new DicomWebThumbnailHandler( |
546 shared_from_this(), source, studyInstanceUid, seriesInstanceUid))); | 546 shared_from_this(), source, studyInstanceUid, seriesInstanceUid))); |
547 Schedule(command.release()); | 547 Schedule(command.release()); |
548 } | 548 } |
549 else if (source.IsOrthanc()) | 549 else if (source.IsOrthanc()) |
550 { | 550 { |
551 // Dummy SOP Instance UID, as we are working at the "series" level | 551 // Dummy SOP Instance UID, as we are working at the "series" level |
552 Orthanc::DicomInstanceHasher hasher(patientId, studyInstanceUid, seriesInstanceUid, "dummy"); | 552 Orthanc::DicomInstanceHasher hasher(patientId, studyInstanceUid, seriesInstanceUid, "dummy"); |
553 | 553 |
554 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); | 554 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
555 command->SetUri("/series/" + hasher.HashSeries()); | 555 command->SetUri("/series/" + hasher.HashSeries()); |
556 command->AcquirePayload(new SelectOrthancInstanceHandler( | 556 command->AcquirePayload(new SelectOrthancInstanceHandler( |
557 shared_from_this(), source, studyInstanceUid, seriesInstanceUid)); | 557 shared_from_this(), source, studyInstanceUid, seriesInstanceUid)); |
558 Schedule(command.release()); | 558 Schedule(command.release()); |
559 } | 559 } |