Mercurial > hg > orthanc-stone
changeset 2403:6ee42446c1b1 refactoring
simplified IObservable::Dispatch()
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Thu, 12 Nov 2026 21:49:29 +0100 |
| parents | a7ae81526abe |
| children | ae04ac9a48af |
| files | OrthancStone/Sources/Loaders/DicomResourcesLoader.cpp OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp OrthancStone/Sources/Messages/IObservable.h OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp |
| diffstat | 6 files changed, 26 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Sources/Loaders/DicomResourcesLoader.cpp Thu Nov 12 21:27:48 2026 +0100 +++ b/OrthancStone/Sources/Loaders/DicomResourcesLoader.cpp Thu Nov 12 21:49:29 2026 +0100 @@ -99,7 +99,7 @@ loader_->BroadcastMessage(message); //loader_->Notify(*loader_, message); - New::IObservable::Dispatch(loader_, message); + New::IObservable::Dispatch(*loader_, message); } boost::shared_ptr<DicomResourcesLoader> GetLoader()
--- a/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp Thu Nov 12 21:27:48 2026 +0100 +++ b/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp Thu Nov 12 21:49:29 2026 +0100 @@ -249,7 +249,7 @@ BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_)); - TypedObservable<DicomVolumeImage::GeometryReadyMessage>::Notify(*this, DicomVolumeImage::GeometryReadyMessage(*volume_)); + Dispatch(*this, DicomVolumeImage::GeometryReadyMessage(*volume_)); } @@ -553,7 +553,7 @@ pixelDataLoaded_ = true; BroadcastMessage(DicomVolumeImage::ContentUpdatedMessage(*volume_)); - TypedObservable<DicomVolumeImage::ContentUpdatedMessage>::Notify(*this, DicomVolumeImage::ContentUpdatedMessage(*volume_)); + Dispatch(*this, DicomVolumeImage::ContentUpdatedMessage(*volume_)); } bool OrthancMultiframeVolumeLoader::HasGeometry() const
--- a/OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Thu Nov 12 21:27:48 2026 +0100 +++ b/OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Thu Nov 12 21:49:29 2026 +0100 @@ -330,7 +330,7 @@ volumeImageReadyInHighQuality_ = true; BroadcastMessage(VolumeImageReadyInHighQuality(*this)); - Dispatch(shared_from_this(), VolumeImageReadyInHighQuality(*this)); + Dispatch(*this, VolumeImageReadyInHighQuality(*this)); } } @@ -415,7 +415,7 @@ BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_)); - Dispatch(shared_from_this(), DicomVolumeImage::GeometryReadyMessage(*volume_)); + Dispatch(*this, DicomVolumeImage::GeometryReadyMessage(*volume_)); #if STONE_TIME_BLOCKING_OPS boost::posix_time::ptime timerEnd = boost::posix_time::microsec_clock::universal_time(); @@ -456,8 +456,7 @@ BroadcastMessage(DicomVolumeImage::ContentUpdatedMessage(*volume_)); - Dispatch(shared_from_this(), DicomVolumeImage::ContentUpdatedMessage(*volume_)); - + Dispatch(*this, DicomVolumeImage::ContentUpdatedMessage(*volume_)); } LOG(TRACE) << "SetSliceContent sliceIndex = " << sliceIndex << " -- will " << " now call ScheduleNextSliceDownload()";
--- a/OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp Thu Nov 12 21:27:48 2026 +0100 +++ b/OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp Thu Nov 12 21:49:29 2026 +0100 @@ -148,7 +148,7 @@ FrameDecodedMessage message(*this, frameIndex, payload.GetQuality(), image, instance, parameters, payload.GetUserPayload()); BroadcastMessage(message); - New::IObservable::Dispatch(shared_from_this(), message); + New::IObservable::Dispatch(*this, message); }
--- a/OrthancStone/Sources/Messages/IObservable.h Thu Nov 12 21:27:48 2026 +0100 +++ b/OrthancStone/Sources/Messages/IObservable.h Thu Nov 12 21:49:29 2026 +0100 @@ -69,10 +69,10 @@ } template <typename Observable, typename Message> - static void Dispatch(const boost::shared_ptr<Observable>& observable, + static void Dispatch(Observable& observable, const Message& message) { - static_cast< TypedObservable<Message>& >(*observable).Notify(*observable, message); + observable.TypedObservable<Message>::Notify(observable, message); } template <typename Message>
--- a/OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp Thu Nov 12 21:27:48 2026 +0100 +++ b/OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp Thu Nov 12 21:49:29 2026 +0100 @@ -1057,7 +1057,7 @@ primitive_.MovePreview(event.GetMainPosition().Apply(canvasToScene_) - sceneClick_, scene); that_.BroadcastMessage(AnnotationChangedMessage(that_)); - that_.TypedObservable<AnnotationChangedMessage>::Notify(that_, AnnotationChangedMessage(that_)); + Dispatch(that_, AnnotationChangedMessage(that_)); that_.Render(scene); return true; @@ -1070,7 +1070,7 @@ alive_ = false; that_.BroadcastMessage(AnnotationChangedMessage(that_)); - that_.TypedObservable<AnnotationChangedMessage>::Notify(that_, AnnotationChangedMessage(that_)); + Dispatch(that_, AnnotationChangedMessage(that_)); that_.Render(scene); } @@ -2409,7 +2409,7 @@ annotation_->SignalMove(annotation_->GetHandle(1), scene); layer_.BroadcastMessage(AnnotationChangedMessage(layer_)); - layer_.TypedObservable<AnnotationChangedMessage>::Notify(layer_, AnnotationChangedMessage(layer_)); + Dispatch(layer_, AnnotationChangedMessage(layer_)); layer_.Render(scene); return true; } @@ -2425,7 +2425,7 @@ annotation_ = NULL; // IsAlive() becomes false layer_.BroadcastMessage(AnnotationAddedMessage(layer_)); - layer_.TypedObservable<AnnotationAddedMessage>::Notify(layer_, AnnotationAddedMessage(layer_)); + Dispatch(layer_, AnnotationAddedMessage(layer_)); layer_.Render(scene); } @@ -2480,7 +2480,7 @@ length_->GetHandle(1).SetCenter(event.GetMainPosition().Apply(canvasToScene_)); length_->SignalMove(length_->GetHandle(1), scene); that_.BroadcastMessage(AnnotationChangedMessage(that_)); - that_.TypedObservable<AnnotationChangedMessage>::Notify(that_, AnnotationChangedMessage(that_)); + Dispatch(that_, AnnotationChangedMessage(that_)); that_.Render(scene); redraw = true; } @@ -2490,7 +2490,7 @@ angle_->GetHandle(2).SetCenter(event.GetMainPosition().Apply(canvasToScene_)); angle_->SignalMove(angle_->GetHandle(2), scene); that_.BroadcastMessage(AnnotationChangedMessage(that_)); - that_.TypedObservable<AnnotationChangedMessage>::Notify(that_, AnnotationChangedMessage(that_)); + Dispatch(that_, AnnotationChangedMessage(that_)); that_.Render(scene); redraw = true; } @@ -2513,7 +2513,7 @@ length_ = NULL; that_.BroadcastMessage(AnnotationChangedMessage(that_)); - that_.TypedObservable<AnnotationChangedMessage>::Notify(that_, AnnotationChangedMessage(that_)); + Dispatch(that_, AnnotationChangedMessage(that_)); that_.Render(scene); } else @@ -2521,7 +2521,7 @@ angle_ = NULL; // IsAlive() becomes false that_.BroadcastMessage(AnnotationAddedMessage(that_)); - that_.TypedObservable<AnnotationAddedMessage>::Notify(that_, AnnotationAddedMessage(that_)); + Dispatch(that_, AnnotationAddedMessage(that_)); that_.Render(scene); } } @@ -2565,7 +2565,7 @@ annotation->UpdateProbe(scene); that.BroadcastMessage(AnnotationAddedMessage(that)); - that.TypedObservable<AnnotationAddedMessage>::Notify(that, AnnotationAddedMessage(that)); + Dispatch(that, AnnotationAddedMessage(that)); that.Render(scene); } @@ -2622,8 +2622,9 @@ GetLayer().BroadcastMessage(AnnotationChangedMessage(GetLayer())); GetLayer().BroadcastMessage(*request); - GetLayer().TypedObservable<AnnotationChangedMessage>::Notify(GetLayer(), AnnotationChangedMessage(GetLayer())); - GetLayer().TypedObservable<TextAnnotationRequiredMessage>::Notify(GetLayer(), *request); + Dispatch(GetLayer(), AnnotationChangedMessage(GetLayer())); + Dispatch(GetLayer(), *request); + GetLayer().Render(scene); } }; @@ -2743,7 +2744,7 @@ { annotations_.insert(new LengthAnnotation(*this, units_, true /* show label */, p1, p2)); BroadcastMessage(AnnotationChangedMessage(*this)); - TypedObservable<AnnotationChangedMessage>::Notify(*this, AnnotationChangedMessage(*this)); + Dispatch(*this, AnnotationChangedMessage(*this)); } @@ -2752,7 +2753,7 @@ { annotations_.insert(new CircleAnnotation(*this, units_, p1, p2)); BroadcastMessage(AnnotationChangedMessage(*this)); - TypedObservable<AnnotationChangedMessage>::Notify(*this, AnnotationChangedMessage(*this)); + Dispatch(*this, AnnotationChangedMessage(*this)); } @@ -2762,7 +2763,7 @@ { annotations_.insert(new AngleAnnotation(*this, p1, p2, p3)); BroadcastMessage(AnnotationChangedMessage(*this)); - TypedObservable<AnnotationChangedMessage>::Notify(*this, AnnotationChangedMessage(*this)); + Dispatch(*this, AnnotationChangedMessage(*this)); } @@ -2903,7 +2904,7 @@ { DeleteAnnotation(&bestHit->GetParentAnnotation()); BroadcastMessage(AnnotationRemovedMessage(*this)); - TypedObservable<AnnotationRemovedMessage>::Notify(*this, AnnotationRemovedMessage(*this)); + Dispatch(*this, AnnotationRemovedMessage(*this)); return new RemoveTracker; } else @@ -3071,6 +3072,6 @@ { annotations_.insert(new TextAnnotation(*this, label, pointedPosition, labelPosition)); BroadcastMessage(AnnotationChangedMessage(*this)); - TypedObservable<AnnotationChangedMessage>::Notify(*this, AnnotationChangedMessage(*this)); + Dispatch(*this, AnnotationChangedMessage(*this)); } }
