comparison Framework/Oracle/WebAssemblyOracle.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
41 class WebAssemblyOracle::TimeoutContext 41 class WebAssemblyOracle::TimeoutContext
42 { 42 {
43 private: 43 private:
44 WebAssemblyOracle& oracle_; 44 WebAssemblyOracle& oracle_;
45 const IObserver& receiver_; 45 const IObserver& receiver_;
46 std::auto_ptr<SleepOracleCommand> command_; 46 std::unique_ptr<SleepOracleCommand> command_;
47 47
48 public: 48 public:
49 TimeoutContext(WebAssemblyOracle& oracle, 49 TimeoutContext(WebAssemblyOracle& oracle,
50 const IObserver& receiver, 50 const IObserver& receiver,
51 IOracleCommand* command) : 51 IOracleCommand* command) :
68 oracle_.EmitMessage(receiver_, message); 68 oracle_.EmitMessage(receiver_, message);
69 } 69 }
70 70
71 static void Callback(void *userData) 71 static void Callback(void *userData)
72 { 72 {
73 std::auto_ptr<TimeoutContext> context(reinterpret_cast<TimeoutContext*>(userData)); 73 std::unique_ptr<TimeoutContext> context(reinterpret_cast<TimeoutContext*>(userData));
74 context->EmitMessage(); 74 context->EmitMessage();
75 } 75 }
76 }; 76 };
77 77
78 78
108 class WebAssemblyOracle::FetchContext : public boost::noncopyable 108 class WebAssemblyOracle::FetchContext : public boost::noncopyable
109 { 109 {
110 private: 110 private:
111 Emitter emitter_; 111 Emitter emitter_;
112 const IObserver& receiver_; 112 const IObserver& receiver_;
113 std::auto_ptr<IOracleCommand> command_; 113 std::unique_ptr<IOracleCommand> command_;
114 std::string expectedContentType_; 114 std::string expectedContentType_;
115 int64_t receiverFingerprint_; 115 int64_t receiverFingerprint_;
116 116
117 public: 117 public:
118 FetchContext(WebAssemblyOracle& oracle, 118 FetchContext(WebAssemblyOracle& oracle,
211 /** 211 /**
212 * Firstly, make a local copy of the fetched information, and 212 * Firstly, make a local copy of the fetched information, and
213 * free data associated with the fetch. 213 * free data associated with the fetch.
214 **/ 214 **/
215 215
216 std::auto_ptr<FetchContext> context(reinterpret_cast<FetchContext*>(fetch->userData)); 216 std::unique_ptr<FetchContext> context(reinterpret_cast<FetchContext*>(fetch->userData));
217 217
218 // an UUID is 36 chars : 32 hex chars + 4 hyphens: char #0 --> char #35 218 // an UUID is 36 chars : 32 hex chars + 4 hyphens: char #0 --> char #35
219 // char #36 is \0. 219 // char #36 is \0.
220 bool callHandler = true; 220 bool callHandler = true;
221 221
350 } 350 }
351 } 351 }
352 352
353 static void FailureCallback(emscripten_fetch_t *fetch) 353 static void FailureCallback(emscripten_fetch_t *fetch)
354 { 354 {
355 std::auto_ptr<FetchContext> context(reinterpret_cast<FetchContext*>(fetch->userData)); 355 std::unique_ptr<FetchContext> context(reinterpret_cast<FetchContext*>(fetch->userData));
356 356
357 { 357 {
358 const size_t kEmscriptenStatusTextSize = sizeof(emscripten_fetch_t::statusText); 358 const size_t kEmscriptenStatusTextSize = sizeof(emscripten_fetch_t::statusText);
359 char message[kEmscriptenStatusTextSize + 1]; 359 char message[kEmscriptenStatusTextSize + 1];
360 memcpy(message, fetch->statusText, kEmscriptenStatusTextSize); 360 memcpy(message, fetch->statusText, kEmscriptenStatusTextSize);
387 class WebAssemblyOracle::FetchCommand : public boost::noncopyable 387 class WebAssemblyOracle::FetchCommand : public boost::noncopyable
388 { 388 {
389 private: 389 private:
390 WebAssemblyOracle& oracle_; 390 WebAssemblyOracle& oracle_;
391 const IObserver& receiver_; 391 const IObserver& receiver_;
392 std::auto_ptr<IOracleCommand> command_; 392 std::unique_ptr<IOracleCommand> command_;
393 Orthanc::HttpMethod method_; 393 Orthanc::HttpMethod method_;
394 std::string url_; 394 std::string url_;
395 std::string body_; 395 std::string body_;
396 HttpHeaders headers_; 396 HttpHeaders headers_;
397 unsigned int timeout_; 397 unsigned int timeout_;
700 { 700 {
701 LOG(TRACE) << "WebAssemblyOracle::Schedule : receiver = " 701 LOG(TRACE) << "WebAssemblyOracle::Schedule : receiver = "
702 << std::hex << &receiver << std::dec 702 << std::hex << &receiver << std::dec
703 << " | Current fingerprint is " << receiver.GetFingerprint(); 703 << " | Current fingerprint is " << receiver.GetFingerprint();
704 704
705 std::auto_ptr<IOracleCommand> protection(command); 705 std::unique_ptr<IOracleCommand> protection(command);
706 706
707 if (command == NULL) 707 if (command == NULL)
708 { 708 {
709 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); 709 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
710 } 710 }