Mercurial > hg > orthanc-stone
changeset 91:81f73efd81a1 wasm
cleaning up
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 29 May 2017 11:18:35 +0200 |
parents | 64e60018943f |
children | 961ee171d933 |
files | Applications/Sdl/SdlEngine.h Framework/Layers/LayerSourceBase.cpp Framework/Toolbox/ObserversRegistry.h Framework/Viewport/IViewport.h Framework/Viewport/WidgetViewport.cpp Framework/Viewport/WidgetViewport.h Framework/Volumes/ISliceableVolume.h Framework/Volumes/VolumeImage.cpp Framework/Volumes/VolumeImage.h Framework/Widgets/LayeredSceneWidget.cpp Framework/Widgets/WorldSceneWidget.cpp |
diffstat | 11 files changed, 32 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Sdl/SdlEngine.h Mon May 29 11:04:18 2017 +0200 +++ b/Applications/Sdl/SdlEngine.h Mon May 29 11:18:35 2017 +0200 @@ -28,7 +28,7 @@ namespace OrthancStone { - class SdlEngine : public IViewport::IChangeObserver + class SdlEngine : public IViewport::IObserver { private: SdlWindow& window_;
--- a/Framework/Layers/LayerSourceBase.cpp Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Layers/LayerSourceBase.cpp Mon May 29 11:18:35 2017 +0200 @@ -78,7 +78,7 @@ } LayerReadyFunctor functor(layer, slice); - observers_.Notify(this, functor); + observers_.Notify(*this, functor); } void LayerSourceBase::NotifyLayerError(const SliceGeometry& slice)
--- a/Framework/Toolbox/ObserversRegistry.h Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Toolbox/ObserversRegistry.h Mon May 29 11:18:35 2017 +0200 @@ -30,54 +30,27 @@ { template < typename Source, - typename Observer = typename Source::IChangeObserver + typename Observer = typename Source::IObserver > class ObserversRegistry : public boost::noncopyable { private: - struct ChangeFunctor : public boost::noncopyable - { - void operator() (Observer& observer, - const Source& source) - { - observer.NotifyChange(source); - } - }; - typedef std::set<Observer*> Observers; Observers observers_; public: template <typename Functor> - void Notify(const Source* source, + void Notify(const Source& source, Functor& functor) { - if (source == NULL) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); - } - for (typename Observers::const_iterator observer = observers_.begin(); observer != observers_.end(); ++observer) { - functor(**observer, *source); + functor(**observer, source); } } - template <typename Functor> - void Notify(const Source* source) - { - // Use the default functor - Functor functor; - Notify(source, functor); - } - - void NotifyChange(const Source* source) - { - Notify<ChangeFunctor>(source); - } - void Register(Observer& observer) { observers_.insert(&observer);
--- a/Framework/Viewport/IViewport.h Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Viewport/IViewport.h Mon May 29 11:18:35 2017 +0200 @@ -33,10 +33,10 @@ class IViewport : public boost::noncopyable { public: - class IChangeObserver : public boost::noncopyable + class IObserver : public boost::noncopyable { public: - virtual ~IChangeObserver() + virtual ~IObserver() { } @@ -49,7 +49,7 @@ virtual void SetDefaultView() = 0; - virtual void Register(IChangeObserver& observer) = 0; + virtual void Register(IObserver& observer) = 0; virtual void SetStatusBar(IStatusBar& statusBar) = 0;
--- a/Framework/Viewport/WidgetViewport.cpp Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Viewport/WidgetViewport.cpp Mon May 29 11:18:35 2017 +0200 @@ -74,7 +74,7 @@ } backgroundChanged_ = true; - observers_.NotifyChange(this); + observers_.Apply(*this, &IObserver::NotifyChange); return *widget; } @@ -83,7 +83,7 @@ void WidgetViewport::NotifyChange(const IWidget& widget) { backgroundChanged_ = true; - observers_.NotifyChange(this); + observers_.Apply(*this, &IObserver::NotifyChange); } @@ -97,7 +97,7 @@ centralWidget_->SetSize(width, height); } - observers_.NotifyChange(this); + observers_.Apply(*this, &IObserver::NotifyChange); } @@ -154,7 +154,7 @@ mouseTracker_.reset(NULL); } - observers_.NotifyChange(this); + observers_.Apply(*this, &IObserver::NotifyChange); } @@ -164,7 +164,7 @@ { mouseTracker_->MouseUp(); mouseTracker_.reset(NULL); - observers_.NotifyChange(this); + observers_.Apply(*this, &IObserver::NotifyChange); } } @@ -195,7 +195,7 @@ if (repaint) { // The scene must be repainted, notify the observers - observers_.NotifyChange(this); + observers_.Apply(*this, &IObserver::NotifyChange); } } @@ -203,7 +203,7 @@ void WidgetViewport::MouseEnter() { isMouseOver_ = true; - observers_.NotifyChange(this); + observers_.Apply(*this, &IObserver::NotifyChange); } @@ -217,7 +217,7 @@ mouseTracker_.reset(NULL); } - observers_.NotifyChange(this); + observers_.Apply(*this, &IObserver::NotifyChange); }
--- a/Framework/Viewport/WidgetViewport.h Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Viewport/WidgetViewport.h Mon May 29 11:18:35 2017 +0200 @@ -53,7 +53,7 @@ virtual void NotifyChange(const IWidget& widget); - virtual void Register(IViewport::IChangeObserver& observer) + virtual void Register(IObserver& observer) { observers_.Register(observer); }
--- a/Framework/Volumes/ISliceableVolume.h Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Volumes/ISliceableVolume.h Mon May 29 11:18:35 2017 +0200 @@ -28,10 +28,10 @@ class ISliceableVolume : public boost::noncopyable { public: - class IChangeObserver : public boost::noncopyable + class IObserver : public boost::noncopyable { public: - virtual ~IChangeObserver() + virtual ~IObserver() { } @@ -42,9 +42,9 @@ { } - virtual void Register(IChangeObserver& observer) = 0; + virtual void Register(IObserver& observer) = 0; - virtual void Unregister(IChangeObserver& observer) = 0; + virtual void Unregister(IObserver& observer) = 0; virtual void Start() = 0;
--- a/Framework/Volumes/VolumeImage.cpp Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Volumes/VolumeImage.cpp Mon May 29 11:18:35 2017 +0200 @@ -182,13 +182,13 @@ } - void VolumeImage::Register(IChangeObserver& observer) + void VolumeImage::Register(IObserver& observer) { observers_.Register(observer); } - void VolumeImage::Unregister(IChangeObserver& observer) + void VolumeImage::Unregister(IObserver& observer) { observers_.Unregister(observer); }
--- a/Framework/Volumes/VolumeImage.h Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Volumes/VolumeImage.h Mon May 29 11:18:35 2017 +0200 @@ -98,9 +98,9 @@ return threads_.size(); } - virtual void Register(IChangeObserver& observer); + virtual void Register(IObserver& observer); - virtual void Unregister(IChangeObserver& observer); + virtual void Unregister(IObserver& observer); virtual void Start();
--- a/Framework/Widgets/LayeredSceneWidget.cpp Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Widgets/LayeredSceneWidget.cpp Mon May 29 11:18:35 2017 +0200 @@ -258,7 +258,7 @@ }; - class LayeredSceneWidget::Layer : public ISliceableVolume::IChangeObserver + class LayeredSceneWidget::Layer : public ISliceableVolume::IObserver { private: boost::mutex mutex_; @@ -562,7 +562,7 @@ InvalidateAllLayers(); SliceChangeFunctor functor(slice); - observers_.Notify(this, functor); + observers_.Notify(*this, functor); }
--- a/Framework/Widgets/WorldSceneWidget.cpp Mon May 29 11:04:18 2017 +0200 +++ b/Framework/Widgets/WorldSceneWidget.cpp Mon May 29 11:18:35 2017 +0200 @@ -38,23 +38,6 @@ } - struct WorldSceneWidget::ViewChangeFunctor - { - const ViewportGeometry& view_; - - ViewChangeFunctor(const ViewportGeometry& view) : - view_(view) - { - } - - void operator() (IWorldObserver& observer, - const WorldSceneWidget& source) - { - observer.NotifyViewChange(source, view_); - } - }; - - struct WorldSceneWidget::SizeChangeFunctor { ViewportGeometry& view_; @@ -144,8 +127,7 @@ that_.view_.SetPan(previousPanX_ + x - downX_, previousPanY_ + y - downY_); - ViewChangeFunctor functor(that_.view_); - that_.observers_.Notify(&that_, functor); + that_.observers_.Apply(that_, &IWorldObserver::NotifyViewChange, that_.view_); } }; @@ -223,8 +205,7 @@ that_.view_.SetPan(panX + static_cast<double>(downX_ - tx), panY + static_cast<double>(downY_ - ty)); - ViewChangeFunctor functor(that_.view_); - that_.observers_.Notify(&that_, functor); + that_.observers_.Apply(that_, &IWorldObserver::NotifyViewChange, that_.view_); } }; @@ -273,7 +254,7 @@ { // With a size observer, let it decide which view to use SizeChangeFunctor functor(view_); - observers_.Notify(this, functor); + observers_.Notify(*this, functor); } } @@ -291,8 +272,7 @@ NotifyChange(); - ViewChangeFunctor functor(view_); - observers_.Notify(this, functor); + observers_.Apply(*this, &IWorldObserver::NotifyViewChange, view_); } @@ -302,8 +282,7 @@ NotifyChange(); - ViewChangeFunctor functor(view_); - observers_.Notify(this, functor); + observers_.Apply(*this, &IWorldObserver::NotifyViewChange, view_); }