comparison Framework/Loaders/DicomResourcesLoader.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 3d26447ddd28
comparison
equal deleted inserted replaced
1297:6ab03e429f06 1299:c38c89684d83
415 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 415 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
416 } 416 }
417 417
418 for (;;) 418 for (;;)
419 { 419 {
420 std::auto_ptr<Orthanc::DicomMap> current(dicomDir.GetItem(index).Clone()); 420 std::unique_ptr<Orthanc::DicomMap> current(dicomDir.GetItem(index).Clone());
421 current->RemoveBinaryTags(); 421 current->RemoveBinaryTags();
422 current->Merge(parent); 422 current->Merge(parent);
423 423
424 std::string type; 424 std::string type;
425 if (!current->LookupStringValue(type, Orthanc::DICOM_TAG_DIRECTORY_RECORD_TYPE, false)) 425 if (!current->LookupStringValue(type, Orthanc::DICOM_TAG_DIRECTORY_RECORD_TYPE, false))
554 const DicomSource& source, 554 const DicomSource& source,
555 const std::string& instanceId, 555 const std::string& instanceId,
556 boost::shared_ptr<unsigned int> remainingCommands, 556 boost::shared_ptr<unsigned int> remainingCommands,
557 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) 557 boost::shared_ptr<Orthanc::IDynamicObject> userPayload)
558 { 558 {
559 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); 559 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
560 command->SetUri("/instances/" + instanceId + "/tags"); 560 command->SetUri("/instances/" + instanceId + "/tags");
561 command->AcquirePayload(new OrthancInstanceTagsHandler(shared_from_this(), target, priority, 561 command->AcquirePayload(new OrthancInstanceTagsHandler(shared_from_this(), target, priority,
562 source, remainingCommands, userPayload)); 562 source, remainingCommands, userPayload));
563 563
564 { 564 {
565 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 565 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
566 lock->Schedule(GetSharedObserver(), priority, command.release()); 566 lock->Schedule(GetSharedObserver(), priority, command.release());
567 } 567 }
568 } 568 }
569 569
570 570
574 Orthanc::ResourceType level, 574 Orthanc::ResourceType level,
575 const std::string& id, 575 const std::string& id,
576 boost::shared_ptr<unsigned int> remainingCommands, 576 boost::shared_ptr<unsigned int> remainingCommands,
577 boost::shared_ptr<Orthanc::IDynamicObject> userPayload) 577 boost::shared_ptr<Orthanc::IDynamicObject> userPayload)
578 { 578 {
579 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); 579 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
580 command->SetUri("/" + GetUri(level) + "/" + id + "/instances"); 580 command->SetUri("/" + GetUri(level) + "/" + id + "/instances");
581 command->AcquirePayload(new OrthancOneChildInstanceHandler(shared_from_this(), target, priority, 581 command->AcquirePayload(new OrthancOneChildInstanceHandler(shared_from_this(), target, priority,
582 source, remainingCommands, userPayload)); 582 source, remainingCommands, userPayload));
583 583
584 { 584 {
585 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 585 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
586 lock->Schedule(GetSharedObserver(), priority, command.release()); 586 lock->Schedule(GetSharedObserver(), priority, command.release());
587 } 587 }
588 } 588 }
589 589
590 590
663 } 663 }
664 664
665 std::map<std::string, std::string> arguments, headers; 665 std::map<std::string, std::string> arguments, headers;
666 SetIncludeTags(arguments, includeTags); 666 SetIncludeTags(arguments, includeTags);
667 667
668 std::auto_ptr<IOracleCommand> command( 668 std::unique_ptr<IOracleCommand> command(
669 source.CreateDicomWebCommand(uri, arguments, headers, 669 source.CreateDicomWebCommand(uri, arguments, headers,
670 new DicomWebHandler(shared_from_this(), target, priority, source, protection))); 670 new DicomWebHandler(shared_from_this(), target, priority, source, protection)));
671 671
672 { 672 {
673 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 673 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
674 lock->Schedule(GetSharedObserver(), priority, command.release()); 674 lock->Schedule(GetSharedObserver(), priority, command.release());
675 } 675 }
676 } 676 }
677 677
678 678
726 } 726 }
727 } 727 }
728 728
729 SetIncludeTags(arguments, includeTags); 729 SetIncludeTags(arguments, includeTags);
730 730
731 std::auto_ptr<IOracleCommand> command( 731 std::unique_ptr<IOracleCommand> command(
732 source.CreateDicomWebCommand(uri, arguments, headers, 732 source.CreateDicomWebCommand(uri, arguments, headers,
733 new DicomWebHandler(shared_from_this(), target, priority, source, protection))); 733 new DicomWebHandler(shared_from_this(), target, priority, source, protection)));
734 734
735 735
736 { 736 {
737 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 737 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
738 lock->Schedule(GetSharedObserver(), priority, command.release()); 738 lock->Schedule(GetSharedObserver(), priority, command.release());
739 } 739 }
740 } 740 }
741 741
742 742
800 { 800 {
801 ScheduleLoadOrthancOneChildInstance(target, priority, source, topLevel, topId, remainingCommands, protection); 801 ScheduleLoadOrthancOneChildInstance(target, priority, source, topLevel, topId, remainingCommands, protection);
802 } 802 }
803 else 803 else
804 { 804 {
805 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); 805 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
806 command->SetUri("/" + GetUri(topLevel) + "/" + topId + "/" + GetUri(bottomLevel)); 806 command->SetUri("/" + GetUri(topLevel) + "/" + topId + "/" + GetUri(bottomLevel));
807 command->AcquirePayload(new OrthancAllChildrenInstancesHandler 807 command->AcquirePayload(new OrthancAllChildrenInstancesHandler
808 (shared_from_this(), target, priority, source, 808 (shared_from_this(), target, priority, source,
809 remainingCommands, bottomLevel, protection)); 809 remainingCommands, bottomLevel, protection));
810 810
811 { 811 {
812 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 812 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
813 lock->Schedule(GetSharedObserver(), priority, command.release()); 813 lock->Schedule(GetSharedObserver(), priority, command.release());
814 } 814 }
815 } 815 }
816 } 816 }
817 817
834 LOG(WARNING) << "If loading DICOMDIR, it is advised to index tag " 834 LOG(WARNING) << "If loading DICOMDIR, it is advised to index tag "
835 << "ReferencedSopInstanceUidInFile (0004,1511)"; 835 << "ReferencedSopInstanceUidInFile (0004,1511)";
836 } 836 }
837 837
838 #if ORTHANC_ENABLE_DCMTK == 1 838 #if ORTHANC_ENABLE_DCMTK == 1
839 std::auto_ptr<ReadFileCommand> command(new ReadFileCommand(path)); 839 std::unique_ptr<ReadFileCommand> command(new ReadFileCommand(path));
840 command->AcquirePayload(new DicomDirHandler(shared_from_this(), target, priority, source, protection)); 840 command->AcquirePayload(new DicomDirHandler(shared_from_this(), target, priority, source, protection));
841 841
842 { 842 {
843 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 843 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
844 lock->Schedule(GetSharedObserver(), priority, command.release()); 844 lock->Schedule(GetSharedObserver(), priority, command.release());
845 } 845 }
846 #else 846 #else
847 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, 847 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
848 "DCMTK is disabled, cannot load DICOMDIR"); 848 "DCMTK is disabled, cannot load DICOMDIR");
858 Orthanc::IDynamicObject* userPayload) 858 Orthanc::IDynamicObject* userPayload)
859 { 859 {
860 boost::shared_ptr<Orthanc::IDynamicObject> protection(userPayload); 860 boost::shared_ptr<Orthanc::IDynamicObject> protection(userPayload);
861 861
862 #if ORTHANC_ENABLE_DCMTK == 1 862 #if ORTHANC_ENABLE_DCMTK == 1
863 std::auto_ptr<ParseDicomFromFileCommand> command(new ParseDicomFromFileCommand(path)); 863 std::unique_ptr<ParseDicomFromFileCommand> command(new ParseDicomFromFileCommand(path));
864 command->SetPixelDataIncluded(includePixelData); 864 command->SetPixelDataIncluded(includePixelData);
865 command->AcquirePayload(new Handler(shared_from_this(), target, priority, source, protection)); 865 command->AcquirePayload(new Handler(shared_from_this(), target, priority, source, protection));
866 866
867 { 867 {
868 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); 868 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
869 lock->Schedule(GetSharedObserver(), priority, command.release()); 869 lock->Schedule(GetSharedObserver(), priority, command.release());
870 } 870 }
871 #else 871 #else
872 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, 872 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
873 "DCMTK is disabled, cannot load DICOM files"); 873 "DCMTK is disabled, cannot load DICOM files");
881 const std::string& dicomDirPath, 881 const std::string& dicomDirPath,
882 const Orthanc::DicomMap& dicomDirEntry, 882 const Orthanc::DicomMap& dicomDirEntry,
883 bool includePixelData, 883 bool includePixelData,
884 Orthanc::IDynamicObject* userPayload) 884 Orthanc::IDynamicObject* userPayload)
885 { 885 {
886 std::auto_ptr<Orthanc::IDynamicObject> protection(userPayload); 886 std::unique_ptr<Orthanc::IDynamicObject> protection(userPayload);
887 887
888 #if ORTHANC_ENABLE_DCMTK == 1 888 #if ORTHANC_ENABLE_DCMTK == 1
889 std::string file; 889 std::string file;
890 if (dicomDirEntry.LookupStringValue(file, Orthanc::DICOM_TAG_REFERENCED_FILE_ID, false)) 890 if (dicomDirEntry.LookupStringValue(file, Orthanc::DICOM_TAG_REFERENCED_FILE_ID, false))
891 { 891 {