Mercurial > hg > orthanc-stone
changeset 2320:c03b0c89c458 refactoring
removed class SeriesFramesLoader::Factory
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Wed, 30 Sep 2026 15:26:27 +0200 |
| parents | 1bb0f5f65063 |
| children | 715ac1d1225a |
| files | Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp OrthancStone/Sources/Loaders/SeriesFramesLoader.h |
| diffstat | 4 files changed, 24 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h Wed Sep 30 15:13:50 2026 +0200 +++ b/Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h Wed Sep 30 15:26:27 2026 +0200 @@ -172,9 +172,7 @@ { std::unique_ptr<OrthancStone::IEnvironment::ILock> lock(context_.GetEnvironment().AcquireLock()); - SeriesFramesLoader::Factory f(*message.GetResources()); - - framesLoader_ = boost::dynamic_pointer_cast<SeriesFramesLoader>(f.Create(context_)); + framesLoader_ = SeriesFramesLoader::Create(context_, *message.GetResources()); Register<SeriesFramesLoader::FrameLoadedMessage>( *framesLoader_, &SdlSimpleViewerApplication::Handle);
--- a/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h Wed Sep 30 15:13:50 2026 +0200 +++ b/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h Wed Sep 30 15:26:27 2026 +0200 @@ -78,9 +78,8 @@ { std::unique_ptr<OrthancStone::IEnvironment::ILock> lock(context_.GetEnvironment().AcquireLock()); - SeriesFramesLoader::Factory f(*message.GetResources()); - framesLoader_ = boost::dynamic_pointer_cast<SeriesFramesLoader>(f.Create(context_)); + framesLoader_ = SeriesFramesLoader::Create(context_, *message.GetResources()); Register<SeriesFramesLoader::FrameLoadedMessage>(*framesLoader_, &SingleFrameViewerApplication::Handle); assert(message.HasUserPayload());
--- a/OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp Wed Sep 30 15:13:50 2026 +0200 +++ b/OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp Wed Sep 30 15:26:27 2026 +0200 @@ -304,25 +304,30 @@ } - void SeriesFramesLoader::Factory::SetDicomDir(const std::string& dicomDirPath, - boost::shared_ptr<LoadedDicomResources> dicomDir) + boost::shared_ptr<SeriesFramesLoader> SeriesFramesLoader::Create(StoneApplication::Context& context, + LoadedDicomResources& instances) { - dicomDirPath_ = dicomDirPath; - dicomDir_ = dicomDir; + const std::string dicomDirPath; + const boost::shared_ptr<LoadedDicomResources> dicomDir; + return Create(context, instances, dicomDirPath, dicomDir); } - boost::shared_ptr<IObserver> SeriesFramesLoader::Factory::Create(StoneApplication::Context& stone) + boost::shared_ptr<SeriesFramesLoader> SeriesFramesLoader::Create(StoneApplication::Context& context, + LoadedDicomResources& instances, + const std::string& dicomDirPath, + boost::shared_ptr<LoadedDicomResources> dicomDir) { boost::shared_ptr<SeriesFramesLoader> loader( - new SeriesFramesLoader(stone, instances_, dicomDirPath_, dicomDir_)); - loader->Register<GetOrthancImageCommand::SuccessMessage>(stone.GetOracleObservable(), &SeriesFramesLoader::Handle); - loader->Register<GetOrthancWebViewerJpegCommand::SuccessMessage>(stone.GetOracleObservable(), &SeriesFramesLoader::Handle); - loader->Register<HttpCommand::SuccessMessage>(stone.GetOracleObservable(), &SeriesFramesLoader::Handle); - loader->Register<OrthancRestApiCommand::SuccessMessage>(stone.GetOracleObservable(), &SeriesFramesLoader::Handle); + new SeriesFramesLoader(context, instances, dicomDirPath, dicomDir)); + + loader->Register<GetOrthancImageCommand::SuccessMessage>(context.GetOracleObservable(), &SeriesFramesLoader::Handle); + loader->Register<GetOrthancWebViewerJpegCommand::SuccessMessage>(context.GetOracleObservable(), &SeriesFramesLoader::Handle); + loader->Register<HttpCommand::SuccessMessage>(context.GetOracleObservable(), &SeriesFramesLoader::Handle); + loader->Register<OrthancRestApiCommand::SuccessMessage>(context.GetOracleObservable(), &SeriesFramesLoader::Handle); #if ORTHANC_ENABLE_DCMTK == 1 - loader->Register<ParseDicomSuccessMessage>(stone.GetOracleObservable(), &SeriesFramesLoader::Handle); + loader->Register<ParseDicomSuccessMessage>(context.GetOracleObservable(), &SeriesFramesLoader::Handle); #endif return loader;
--- a/OrthancStone/Sources/Loaders/SeriesFramesLoader.h Wed Sep 30 15:13:50 2026 +0200 +++ b/OrthancStone/Sources/Loaders/SeriesFramesLoader.h Wed Sep 30 15:26:27 2026 +0200 @@ -141,25 +141,13 @@ }; - class Factory : public boost::noncopyable // TODO Refactoring - remove this? - { - private: - LoadedDicomResources& instances_; - std::string dicomDirPath_; - boost::shared_ptr<LoadedDicomResources> dicomDir_; + static boost::shared_ptr<SeriesFramesLoader> Create(StoneApplication::Context& context, + LoadedDicomResources& instances); - public: - // No "const" because "LoadedDicomResources::GetResource()" will call "Flatten()" - explicit Factory(LoadedDicomResources& instances) : - instances_(instances) - { - } - - void SetDicomDir(const std::string& dicomDirPath, - boost::shared_ptr<LoadedDicomResources> dicomDir); - - boost::shared_ptr<IObserver> Create(StoneApplication::Context& context); - }; + static boost::shared_ptr<SeriesFramesLoader> Create(StoneApplication::Context& context, + LoadedDicomResources& instances, + const std::string& dicomDirPath, + boost::shared_ptr<LoadedDicomResources> dicomDir); const SeriesOrderedFrames& GetOrderedFrames() const {
