Mercurial > hg > orthanc-stone
changeset 2286:1d75fb03e228 refactoring
simplification
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Wed, 23 Sep 2026 10:04:51 +0200 |
| parents | cad7215828c2 |
| children | 71796ca3743c |
| files | OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h |
| diffstat | 2 files changed, 24 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- 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<IObserver> receiver_; - std::unique_ptr<IOracleCommand> command_; - std::string expectedContentType_; + std::unique_ptr<IOracleCallback> callback_; + WebAssemblyOracle& oracle_; + std::string expectedContentType_; public: FetchContext(WebAssemblyOracle& oracle, boost::weak_ptr<IObserver> 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<IOracleClient>& client, + IOracleCommand* command /* takes ownership */) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); // TODO Refactoring + } + + void WebAssemblyOracle::SetDicomCacheSize(size_t size) { #if ORTHANC_ENABLE_DCMTK == 1
--- 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<std::string, std::string> HttpHeaders; @@ -70,7 +71,7 @@ void SetOrthancUrl(FetchCommand& command, const std::string& uri) const; - + void Execute(boost::weak_ptr<IObserver> receiver, HttpCommand* command); @@ -110,10 +111,15 @@ { oracleObservable_.EmitMessage(observer, message); } - + + // TODO Refactoring - Remove old flavor virtual bool Schedule(boost::shared_ptr<IObserver> receiver, IOracleCommand* command) ORTHANC_OVERRIDE; + virtual void Submit(IEnvironment& environment, + const boost::shared_ptr<IOracleClient>& client, + IOracleCommand* command /* takes ownership */) ORTHANC_OVERRIDE; + IObservable& GetOracleObservable() { return oracleObservable_;
