# HG changeset patch # User Sebastien Jodogne # Date 1790150691 -7200 # Node ID 1d75fb03e22819334d79bdc40ca240d7669b6cab # Parent cad7215828c26bb4482a77a42fdd81ff33d5a42e simplification diff -r cad7215828c2 -r 1d75fb03e228 OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp --- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp Wed Sep 23 09:41:06 2026 +0200 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp Wed Sep 23 10:04:51 2026 +0200 @@ -99,19 +99,17 @@ class WebAssemblyOracle::FetchContext : public boost::noncopyable { private: - WebAssemblyOracle& oracle_; - boost::weak_ptr receiver_; - std::unique_ptr command_; - std::string expectedContentType_; + std::unique_ptr callback_; + WebAssemblyOracle& oracle_; + std::string expectedContentType_; public: FetchContext(WebAssemblyOracle& oracle, boost::weak_ptr receiver, IOracleCommand* command, const std::string& expectedContentType) : + callback_(new OldOracleCallback(command, receiver, oracle)), oracle_(oracle), - receiver_(receiver), - command_(command), expectedContentType_(expectedContentType) { if (Orthanc::Logging::IsTraceLevelEnabled()) @@ -120,11 +118,6 @@ LOG(TRACE) << "WebAssemblyOracle::FetchContext::FetchContext() | " << "receiver address = " << std::hex << receiver.lock().get(); } - - if (command == NULL) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); - } } const std::string& GetExpectedContentType() const @@ -134,29 +127,13 @@ void EmitException(const Orthanc::OrthancException& exception) { - if (command_.get() == NULL) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); - } - else - { - OracleCommandExceptionMessage message(*command_, exception); - oracle_.EmitMessage(receiver_, message); - } + callback_->NotifyError(exception); } void ProcessFetchResult(const std::string& answer, const HttpHeaders& headers) { - if (command_.get() == NULL) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); - } - else - { - OldOracleCallback callback(command_.release(), receiver_, oracle_); - oracle_.ProcessFetchResult(callback, answer, headers); - } + oracle_.ProcessFetchResult(*callback_, answer, headers); } static void SuccessCallback(emscripten_fetch_t *fetch) @@ -802,6 +779,14 @@ } + void WebAssemblyOracle::Submit(IEnvironment& environment, + const boost::shared_ptr& client, + IOracleCommand* command /* takes ownership */) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); // TODO Refactoring + } + + void WebAssemblyOracle::SetDicomCacheSize(size_t size) { #if ORTHANC_ENABLE_DCMTK == 1 diff -r cad7215828c2 -r 1d75fb03e228 OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h --- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h Wed Sep 23 09:41:06 2026 +0200 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h Wed Sep 23 10:04:51 2026 +0200 @@ -58,8 +58,9 @@ class ParseDicomFromWadoCommand; class WebAssemblyOracle : - public IOracle, - public IMessageEmitter + public IOracle, // TODO Refactoring - Remove old flavor + public IMessageEmitter, + public New::IOracle { private: typedef std::map HttpHeaders; @@ -70,7 +71,7 @@ void SetOrthancUrl(FetchCommand& command, const std::string& uri) const; - + void Execute(boost::weak_ptr receiver, HttpCommand* command); @@ -110,10 +111,15 @@ { oracleObservable_.EmitMessage(observer, message); } - + + // TODO Refactoring - Remove old flavor virtual bool Schedule(boost::shared_ptr receiver, IOracleCommand* command) ORTHANC_OVERRIDE; + virtual void Submit(IEnvironment& environment, + const boost::shared_ptr& client, + IOracleCommand* command /* takes ownership */) ORTHANC_OVERRIDE; + IObservable& GetOracleObservable() { return oracleObservable_;