comparison Applications/ApplicationToolbox.cpp @ 199:a1c265cb2174

replacing deprecated std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 06 Jul 2020 16:29:41 +0200
parents f299c191cd76
children 1e864138f0da
comparison
equal deleted inserted replaced
198:2d3fe6967894 199:a1c265cb2174
22 #include "ApplicationToolbox.h" 22 #include "ApplicationToolbox.h"
23 23
24 #include "../Framework/Inputs/OpenSlideLibrary.h" 24 #include "../Framework/Inputs/OpenSlideLibrary.h"
25 #include "../Framework/MultiThreading/BagOfTasksProcessor.h" 25 #include "../Framework/MultiThreading/BagOfTasksProcessor.h"
26 26
27 #include <Compatibility.h> // For std::unique_ptr
27 #include <DicomParsing/FromDcmtkBridge.h> 28 #include <DicomParsing/FromDcmtkBridge.h>
28 #include <HttpClient.h> 29 #include <HttpClient.h>
29 #include <Logging.h> 30 #include <Logging.h>
30 #include <OrthancException.h> 31 #include <OrthancException.h>
31 #include <SystemToolbox.h> 32 #include <SystemToolbox.h>
105 { 106 {
106 // Submit the tasks to a newly-created processor 107 // Submit the tasks to a newly-created processor
107 LOG(WARNING) << "Running " << tasks.GetSize() << " tasks"; 108 LOG(WARNING) << "Running " << tasks.GetSize() << " tasks";
108 LOG(WARNING) << "Using " << threadsCount << " threads for the computation"; 109 LOG(WARNING) << "Using " << threadsCount << " threads for the computation";
109 Orthanc::BagOfTasksProcessor processor(threadsCount); 110 Orthanc::BagOfTasksProcessor processor(threadsCount);
110 std::auto_ptr<Orthanc::BagOfTasksProcessor::Handle> handle(processor.Submit(tasks)); 111 std::unique_ptr<Orthanc::BagOfTasksProcessor::Handle> handle(processor.Submit(tasks));
111 112
112 // Start a thread to display the progress 113 // Start a thread to display the progress
113 bool done = false; 114 bool done = false;
114 boost::thread progress(PrintProgress, handle.get(), &done); 115 boost::thread progress(PrintProgress, handle.get(), &done);
115 116
142 unsigned int size = tasks.GetSize(); 143 unsigned int size = tasks.GetSize();
143 144
144 // No multithreading 145 // No multithreading
145 while (!tasks.IsEmpty()) 146 while (!tasks.IsEmpty())
146 { 147 {
147 std::auto_ptr<Orthanc::ICommand> task(tasks.Pop()); 148 std::unique_ptr<Orthanc::ICommand> task(tasks.Pop());
148 if (task->Execute()) 149 if (task->Execute())
149 { 150 {
150 unsigned int progress = static_cast<unsigned int>(100.0f * 151 unsigned int progress = static_cast<unsigned int>(100.0f *
151 static_cast<float>((size - tasks.GetSize())) / 152 static_cast<float>((size - tasks.GetSize())) /
152 static_cast<float>(size)); 153 static_cast<float>(size));