Mercurial > hg > orthanc-stone
changeset 2303:a683376c19f0 refactoring
removed old oracle implementations
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Sun, 27 Sep 2026 12:12:11 +0200 |
| parents | c16e2c80f17f |
| children | cb959d9a539a |
| files | OrthancStone/Sources/Loaders/GenericLoadersContext.cpp OrthancStone/Sources/Loaders/GenericLoadersContext.h OrthancStone/Sources/Oracle/ThreadedOracle.cpp OrthancStone/Sources/Oracle/ThreadedOracle.h OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.cpp OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.h OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h OrthancStone/Sources/StoneApplication.cpp OrthancStone/Sources/StoneApplication.h |
| diffstat | 10 files changed, 17 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Sources/Loaders/GenericLoadersContext.cpp Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/Loaders/GenericLoadersContext.cpp Sun Sep 27 12:12:11 2026 +0200 @@ -103,7 +103,6 @@ unsigned int maxStandardPriority, unsigned int maxLowPriority) { - dynamic_cast<ThreadedOracle&>(StoneApplication::GetInstance().GetOldOracle()).SetMessageEmitter(*this); scheduler_ = OracleScheduler::Create(StoneApplication::GetInstance(), *this, maxHighPriority, maxStandardPriority, maxLowPriority);
--- a/OrthancStone/Sources/Loaders/GenericLoadersContext.h Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/Loaders/GenericLoadersContext.h Sun Sep 27 12:12:11 2026 +0200 @@ -43,7 +43,7 @@ // "Recursive mutex" is necessary, to be able to run // "ILoaderFactory" from a message handler triggered by // "EmitMessage()" - boost::recursive_mutex mutex_; + boost::recursive_mutex mutex_; // TODO Refactoring - This is redundant with IEnvironment IObservable oracleObservable_; boost::shared_ptr<OracleScheduler> scheduler_;
--- a/OrthancStone/Sources/Oracle/ThreadedOracle.cpp Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/Oracle/ThreadedOracle.cpp Sun Sep 27 12:12:11 2026 +0200 @@ -153,7 +153,6 @@ ThreadedOracle::ThreadedOracle(const StoneApplication::Configuration& configuration) : - emitter_(NULL), configuration_(configuration), sleepingThread_(new SleepRunnable, configuration.GetWorkersTimeResolution()) { @@ -230,21 +229,4 @@ SubmitInternal(new OracleCallback(environment, client, protection.release())); } - - - bool ThreadedOracle::Schedule(boost::shared_ptr<IObserver> receiver, - IOracleCommand* command) - { - std::unique_ptr<IOracleCommand> protection(command); - - if (emitter_ == NULL) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); - } - else - { - SubmitInternal(new OldOracleCallback(protection.release(), receiver, *emitter_)); - return true; - } - } }
--- a/OrthancStone/Sources/Oracle/ThreadedOracle.h Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/Oracle/ThreadedOracle.h Sun Sep 27 12:12:11 2026 +0200 @@ -53,15 +53,12 @@ namespace OrthancStone { - class ThreadedOracle : - public ::OrthancStone::IOracle, // TODO Refactoring - Remove this - public ::OrthancStone::New::IOracle + class ThreadedOracle : public ::OrthancStone::New::IOracle { private: class GenericRunnable; class SleepRunnable; - IMessageEmitter* emitter_; // TODO Refactoring - Remove this StoneApplication::Configuration configuration_; RunnableThread sleepingThread_; Orthanc::ThreadPool threadPool_; @@ -75,11 +72,6 @@ public: ThreadedOracle(const StoneApplication::Configuration& configuration); - void SetMessageEmitter(IMessageEmitter& emitter) // TODO Refactoring - Remove this - { - emitter_ = &emitter; - } - void Start(); void Stop(); @@ -87,8 +79,5 @@ virtual void Submit(IEnvironment& environment, const boost::shared_ptr<IOracleClient>& client, IOracleCommand* command /* takes ownership */) ORTHANC_OVERRIDE; - - virtual bool Schedule(boost::shared_ptr<IObserver> receiver, - IOracleCommand* command) ORTHANC_OVERRIDE; }; }
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.cpp Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.cpp Sun Sep 27 12:12:11 2026 +0200 @@ -43,7 +43,7 @@ virtual IObservable& GetOracleObservable() const ORTHANC_OVERRIDE { - return that_.oracle_.GetOracleObservable(); + return that_.oracleObservable_; } virtual void Schedule(boost::shared_ptr<IObserver> receiver, @@ -80,9 +80,9 @@ WebAssemblyLoadersContext::WebAssemblyLoadersContext(unsigned int maxHighPriority, unsigned int maxStandardPriority, unsigned int maxLowPriority) : - oracle_(dynamic_cast<WebAssemblyOracle&>(StoneApplication::GetInstance().GetOldOracle())) + oracle_(dynamic_cast<WebAssemblyOracle&>(StoneApplication::GetInstance().GetOracle())) { - scheduler_ = OracleScheduler::Create(StoneApplication::GetInstance(), oracle_, + scheduler_ = OracleScheduler::Create(StoneApplication::GetInstance(), *this, maxHighPriority, maxStandardPriority, maxLowPriority); if (!scheduler_)
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.h Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.h Sun Sep 27 12:12:11 2026 +0200 @@ -32,11 +32,14 @@ namespace OrthancStone { // TODO Refactoring - Remove this class - class WebAssemblyLoadersContext : public ILoadersContext + class WebAssemblyLoadersContext : + public ILoadersContext, + public IMessageEmitter { private: class Locker; - + + IObservable oracleObservable_; WebAssemblyOracle& oracle_; boost::shared_ptr<OracleScheduler> scheduler_; std::list< boost::shared_ptr<IObserver> > loaders_; @@ -51,6 +54,12 @@ return new WebAssemblyOracle::CachedInstanceAccessor(oracle_, sopInstanceUid); } + virtual void EmitMessage(boost::weak_ptr<IObserver> observer, + const IMessage& message) ORTHANC_OVERRIDE + { + oracleObservable_.EmitMessage(observer, message); + } + virtual ILock* Lock() ORTHANC_OVERRIDE; }; }
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp Sun Sep 27 12:12:11 2026 +0200 @@ -806,18 +806,6 @@ } - bool WebAssemblyOracle::Schedule(boost::shared_ptr<IObserver> receiver, - IOracleCommand* command) - { - LOG(TRACE) << "WebAssemblyOracle::Schedule : receiver = " - << std::hex << receiver.get(); - - Submit(new OldOracleCallback(command, receiver, *this)); - - return true; - } - - void WebAssemblyOracle::Submit(IEnvironment& environment, const boost::shared_ptr<IOracleClient>& client, IOracleCommand* command /* takes ownership */)
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h Sun Sep 27 12:12:11 2026 +0200 @@ -52,10 +52,7 @@ namespace OrthancStone { - class WebAssemblyOracle : - public IOracle, // TODO Refactoring - Remove old flavor - public IMessageEmitter, // TODO Refactoring - Remove old flavor - public New::IOracle + class WebAssemblyOracle : public New::IOracle { private: typedef std::map<std::string, std::string> HttpHeaders; @@ -77,7 +74,6 @@ void ExecuteParseDicomFromWadoCommand(IOracleCallback* callback); StoneApplication::Configuration configuration_; - IObservable oracleObservable_; #if ORTHANC_ENABLE_DCMTK == 1 std::unique_ptr<ParsedDicomCache> dicomCache_; @@ -92,24 +88,10 @@ public: WebAssemblyOracle(const StoneApplication::Configuration& configuration); - virtual void EmitMessage(boost::weak_ptr<IObserver> observer, - const IMessage& message) ORTHANC_OVERRIDE - { - oracleObservable_.EmitMessage(observer, message); - } - - 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_; - } - class CachedInstanceAccessor : public boost::noncopyable { private:
--- a/OrthancStone/Sources/StoneApplication.cpp Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/StoneApplication.cpp Sun Sep 27 12:12:11 2026 +0200 @@ -258,13 +258,6 @@ } - IOracle& StoneApplication::GetOldOracle() - { - assert(pimpl_ != NULL); - return pimpl_->GetOracle(); - } - - New::IOracle& StoneApplication::GetOracle() { assert(pimpl_ != NULL);
--- a/OrthancStone/Sources/StoneApplication.h Sun Sep 27 11:24:24 2026 +0200 +++ b/OrthancStone/Sources/StoneApplication.h Sun Sep 27 12:12:11 2026 +0200 @@ -116,8 +116,6 @@ IEnvironment& GetEnvironment(); - IOracle& GetOldOracle(); // TODO Refactoring - Remove this - New::IOracle& GetOracle(); }; }
