comparison Framework/Loaders/SeriesFramesLoader.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 1f877e0846fe
comparison
equal deleted inserted replaced
1297:6ab03e429f06 1299:c38c89684d83
45 std::string sopInstanceUid_; // Only used for debug purpose 45 std::string sopInstanceUid_; // Only used for debug purpose
46 unsigned int quality_; 46 unsigned int quality_;
47 bool hasWindowing_; 47 bool hasWindowing_;
48 float windowingCenter_; 48 float windowingCenter_;
49 float windowingWidth_; 49 float windowingWidth_;
50 std::auto_ptr<Orthanc::IDynamicObject> userPayload_; 50 std::unique_ptr<Orthanc::IDynamicObject> userPayload_;
51 51
52 public: 52 public:
53 Payload(const DicomSource& source, 53 Payload(const DicomSource& source,
54 size_t seriesIndex, 54 size_t seriesIndex,
55 const std::string& sopInstanceUid, 55 const std::string& sopInstanceUid,
167 void SeriesFramesLoader::HandleDicom(const Payload& payload, 167 void SeriesFramesLoader::HandleDicom(const Payload& payload,
168 Orthanc::ParsedDicomFile& dicom) 168 Orthanc::ParsedDicomFile& dicom)
169 { 169 {
170 size_t frameIndex = frames_.GetFrameIndex(payload.GetSeriesIndex()); 170 size_t frameIndex = frames_.GetFrameIndex(payload.GetSeriesIndex());
171 171
172 std::auto_ptr<Orthanc::ImageAccessor> decoded; 172 std::unique_ptr<Orthanc::ImageAccessor> decoded;
173 decoded.reset(Orthanc::DicomImageDecoder::Decode(dicom, frameIndex)); 173 decoded.reset(Orthanc::DicomImageDecoder::Decode(dicom, frameIndex));
174 174
175 if (decoded.get() == NULL) 175 if (decoded.get() == NULL)
176 { 176 {
177 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); 177 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
379 const DicomSource& source, 379 const DicomSource& source,
380 size_t index, 380 size_t index,
381 unsigned int quality, 381 unsigned int quality,
382 Orthanc::IDynamicObject* userPayload) 382 Orthanc::IDynamicObject* userPayload)
383 { 383 {
384 std::auto_ptr<Orthanc::IDynamicObject> protection(userPayload); 384 std::unique_ptr<Orthanc::IDynamicObject> protection(userPayload);
385 385
386 if (index >= frames_.GetFramesCount() || 386 if (index >= frames_.GetFramesCount() ||
387 quality >= source.GetQualityCount()) 387 quality >= source.GetQualityCount())
388 { 388 {
389 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 389 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
411 assert(quality == 0); 411 assert(quality == 0);
412 412
413 std::string file; 413 std::string file;
414 if (dicomDir_->LookupStringValue(file, sopInstanceUid, Orthanc::DICOM_TAG_REFERENCED_FILE_ID)) 414 if (dicomDir_->LookupStringValue(file, sopInstanceUid, Orthanc::DICOM_TAG_REFERENCED_FILE_ID))
415 { 415 {
416 std::auto_ptr<ParseDicomFromFileCommand> command(new ParseDicomFromFileCommand(dicomDirPath_, file)); 416 std::unique_ptr<ParseDicomFromFileCommand> command(new ParseDicomFromFileCommand(dicomDirPath_, file));
417 command->SetPixelDataIncluded(true); 417 command->SetPixelDataIncluded(true);
418 command->AcquirePayload(new Payload(source, index, sopInstanceUid, quality, protection.release())); 418 command->AcquirePayload(new Payload(source, index, sopInstanceUid, quality, protection.release()));
419 419
420 { 420 {
421 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 421 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
422 lock->Schedule(GetSharedObserver(), priority, command.release()); 422 lock->Schedule(GetSharedObserver(), priority, command.release());
423 } 423 }
424 } 424 }
425 else 425 else
426 { 426 {
450 std::map<std::string, std::string> arguments, headers; 450 std::map<std::string, std::string> arguments, headers;
451 arguments["window"] = (boost::lexical_cast<std::string>(c) + "," + 451 arguments["window"] = (boost::lexical_cast<std::string>(c) + "," +
452 boost::lexical_cast<std::string>(w) + ",linear"); 452 boost::lexical_cast<std::string>(w) + ",linear");
453 headers["Accept"] = "image/jpeg"; 453 headers["Accept"] = "image/jpeg";
454 454
455 std::auto_ptr<Payload> payload(new Payload(source, index, sopInstanceUid, quality, protection.release())); 455 std::unique_ptr<Payload> payload(new Payload(source, index, sopInstanceUid, quality, protection.release()));
456 payload->SetWindowing(c, w); 456 payload->SetWindowing(c, w);
457 457
458 { 458 {
459 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 459 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
460 lock->Schedule(GetSharedObserver(), priority, 460 lock->Schedule(GetSharedObserver(), priority,
461 source.CreateDicomWebCommand(uri + "/rendered", arguments, headers, payload.release())); 461 source.CreateDicomWebCommand(uri + "/rendered", arguments, headers, payload.release()));
462 } 462 }
463 } 463 }
464 else 464 else
465 { 465 {
466 assert((source.HasDicomWebRendered() && quality == 1) || 466 assert((source.HasDicomWebRendered() && quality == 1) ||
467 (!source.HasDicomWebRendered() && quality == 0)); 467 (!source.HasDicomWebRendered() && quality == 0));
468 468
469 #if ORTHANC_ENABLE_DCMTK == 1 469 #if ORTHANC_ENABLE_DCMTK == 1
470 std::auto_ptr<Payload> payload(new Payload(source, index, sopInstanceUid, quality, protection.release())); 470 std::unique_ptr<Payload> payload(new Payload(source, index, sopInstanceUid, quality, protection.release()));
471 471
472 const std::map<std::string, std::string> empty; 472 const std::map<std::string, std::string> empty;
473 473
474 std::auto_ptr<ParseDicomFromWadoCommand> command( 474 std::unique_ptr<ParseDicomFromWadoCommand> command(
475 new ParseDicomFromWadoCommand(sopInstanceUid, source.CreateDicomWebCommand(uri, empty, empty, NULL))); 475 new ParseDicomFromWadoCommand(sopInstanceUid, source.CreateDicomWebCommand(uri, empty, empty, NULL)));
476 command->AcquirePayload(payload.release()); 476 command->AcquirePayload(payload.release());
477 477
478 { 478 {
479 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 479 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
480 lock->Schedule(GetSharedObserver(), priority, command.release()); 480 lock->Schedule(GetSharedObserver(), priority, command.release());
481 } 481 }
482 #else 482 #else
483 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, 483 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented,
484 "DCMTK is not enabled, cannot parse a DICOM instance"); 484 "DCMTK is not enabled, cannot parse a DICOM instance");
505 505
506 const DicomInstanceParameters& parameters = frames_.GetInstanceParameters(index); 506 const DicomInstanceParameters& parameters = frames_.GetInstanceParameters(index);
507 507
508 if (quality == 0 && source.HasOrthancWebViewer1()) 508 if (quality == 0 && source.HasOrthancWebViewer1())
509 { 509 {
510 std::auto_ptr<GetOrthancWebViewerJpegCommand> command(new GetOrthancWebViewerJpegCommand); 510 std::unique_ptr<GetOrthancWebViewerJpegCommand> command(new GetOrthancWebViewerJpegCommand);
511 command->SetInstance(orthancId); 511 command->SetInstance(orthancId);
512 command->SetExpectedPixelFormat(parameters.GetExpectedPixelFormat()); 512 command->SetExpectedPixelFormat(parameters.GetExpectedPixelFormat());
513 command->AcquirePayload(new Payload(source, index, sopInstanceUid, quality, protection.release())); 513 command->AcquirePayload(new Payload(source, index, sopInstanceUid, quality, protection.release()));
514 514
515 { 515 {
516 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 516 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
517 lock->Schedule(GetSharedObserver(), priority, command.release()); 517 lock->Schedule(GetSharedObserver(), priority, command.release());
518 } 518 }
519 } 519 }
520 else if (quality == 0 && source.HasOrthancAdvancedPreview()) 520 else if (quality == 0 && source.HasOrthancAdvancedPreview())
521 { 521 {
526 assert(quality <= 1); 526 assert(quality <= 1);
527 assert(quality == 0 || 527 assert(quality == 0 ||
528 source.HasOrthancWebViewer1() || 528 source.HasOrthancWebViewer1() ||
529 source.HasOrthancAdvancedPreview()); 529 source.HasOrthancAdvancedPreview());
530 530
531 std::auto_ptr<GetOrthancImageCommand> command(new GetOrthancImageCommand); 531 std::unique_ptr<GetOrthancImageCommand> command(new GetOrthancImageCommand);
532 command->SetFrameUri(orthancId, frames_.GetFrameIndex(index), parameters.GetExpectedPixelFormat()); 532 command->SetFrameUri(orthancId, frames_.GetFrameIndex(index), parameters.GetExpectedPixelFormat());
533 command->SetExpectedPixelFormat(parameters.GetExpectedPixelFormat()); 533 command->SetExpectedPixelFormat(parameters.GetExpectedPixelFormat());
534 command->SetHttpHeader("Accept", Orthanc::MIME_PAM); 534 command->SetHttpHeader("Accept", Orthanc::MIME_PAM);
535 command->AcquirePayload(new Payload(source, index, sopInstanceUid, quality, protection.release())); 535 command->AcquirePayload(new Payload(source, index, sopInstanceUid, quality, protection.release()));
536 536
537 { 537 {
538 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 538 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
539 lock->Schedule(GetSharedObserver(), priority, command.release()); 539 lock->Schedule(GetSharedObserver(), priority, command.release());
540 } 540 }
541 } 541 }
542 } 542 }
543 else 543 else