changeset 268:5bd4161bf11b am-2

removed constness of the observable when emitting a message
author am@osimis.io
date Wed, 22 Aug 2018 15:08:15 +0200
parents 89d02de83c03
children 0dfa83535cd7
files Applications/Samples/SimpleViewerApplication.h Framework/Layers/OrthancFrameLayerSource.cpp Framework/Layers/OrthancFrameLayerSource.h Framework/Messages/IObservable.h Framework/Messages/IObserver.h Framework/Messages/MessageBroker.cpp Framework/Messages/MessageBroker.h Framework/SmartLoader.cpp Framework/SmartLoader.h Framework/Toolbox/IWebService.h Framework/Toolbox/OrthancSlicesLoader.cpp Framework/Toolbox/OrthancSlicesLoader.h Framework/Widgets/LayerWidget.cpp Framework/Widgets/LayerWidget.h Resources/CMake/OrthancStoneConfiguration.cmake UnitTestsSources/TestMessageBroker.cpp
diffstat 16 files changed, 23 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/SimpleViewerApplication.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Applications/Samples/SimpleViewerApplication.h	Wed Aug 22 15:08:15 2018 +0200
@@ -175,10 +175,10 @@
       //      }
 
 
-      virtual void HandleMessage(const IObservable& from, const IMessage& message) {
+      virtual void HandleMessage(IObservable& from, const IMessage& message) {
         switch (message.GetType()) {
         case MessageType_Widget_GeometryChanged:
-          //TODO remove constness !! dynamic_cast<const LayerWidget&>(from).SetDefaultView();
+          dynamic_cast<LayerWidget&>(from).SetDefaultView();
           break;
         default:
           VLOG("unhandled message type" << message.GetType());
--- a/Framework/Layers/OrthancFrameLayerSource.cpp	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Layers/OrthancFrameLayerSource.cpp	Wed Aug 22 15:08:15 2018 +0200
@@ -31,7 +31,7 @@
 
 namespace OrthancStone
 {
-  void OrthancFrameLayerSource::HandleMessage(const IObservable& from, const IMessage& message)
+  void OrthancFrameLayerSource::HandleMessage(IObservable& from, const IMessage& message)
   {
     switch (message.GetType())
     {
--- a/Framework/Layers/OrthancFrameLayerSource.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Layers/OrthancFrameLayerSource.h	Wed Aug 22 15:08:15 2018 +0200
@@ -69,6 +69,6 @@
 
     virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice);
 
-    virtual void HandleMessage(const IObservable& from, const IMessage& message);
+    virtual void HandleMessage(IObservable& from, const IMessage& message);
   };
 }
--- a/Framework/Messages/IObservable.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Messages/IObservable.h	Wed Aug 22 15:08:15 2018 +0200
@@ -61,7 +61,7 @@
     {
     }
 
-    void EmitMessage(const IMessage& message) const
+    void EmitMessage(const IMessage& message)
     {
       if (emittableMessages_.find(message.GetType()) == emittableMessages_.end())
       {
--- a/Framework/Messages/IObserver.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Messages/IObserver.h	Wed Aug 22 15:08:15 2018 +0200
@@ -49,14 +49,14 @@
       broker_.Unregister(*this);
     }
 
-    void HandleMessage_(const IObservable &from, const IMessage &message)
+    void HandleMessage_(IObservable &from, const IMessage &message)
     {
       assert(handledMessages_.find(message.GetType()) != handledMessages_.end()); // please declare the messages that you're handling
 
       HandleMessage(from, message);
     }
 
-    virtual void HandleMessage(const IObservable& from, const IMessage& message) = 0;
+    virtual void HandleMessage(IObservable& from, const IMessage& message) = 0;
 
 
     const std::set<MessageType>& GetHandledMessages() const
--- a/Framework/Messages/MessageBroker.cpp	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Messages/MessageBroker.cpp	Wed Aug 22 15:08:15 2018 +0200
@@ -30,7 +30,7 @@
 
 namespace OrthancStone {
 
-  void MessageBroker::EmitMessage(const IObservable& from, std::set<IObserver*> observers, const IMessage& message)
+  void MessageBroker::EmitMessage(IObservable& from, std::set<IObserver*> observers, const IMessage& message)
   {
     std::vector<IObserver*> activeObservers;
     std::set_intersection(observers.begin(),
--- a/Framework/Messages/MessageBroker.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Messages/MessageBroker.h	Wed Aug 22 15:08:15 2018 +0200
@@ -56,7 +56,7 @@
       activeObservers_.erase(&observer);
     }
 
-    void EmitMessage(const IObservable& from, std::set<IObserver*> observers, const IMessage& message);
+    void EmitMessage(IObservable& from, std::set<IObserver*> observers, const IMessage& message);
   };
 
 }
--- a/Framework/SmartLoader.cpp	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/SmartLoader.cpp	Wed Aug 22 15:08:15 2018 +0200
@@ -38,7 +38,7 @@
     DeclareIgnoredMessage(MessageType_LayerSource_SliceChanged);
   }
 
-  void SmartLoader::HandleMessage(const IObservable& from, const IMessage& message)
+  void SmartLoader::HandleMessage(IObservable& from, const IMessage& message)
   {
     switch (message.GetType()) {
     case MessageType_LayerSource_GeometryReady:
--- a/Framework/SmartLoader.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/SmartLoader.h	Wed Aug 22 15:08:15 2018 +0200
@@ -36,7 +36,7 @@
   public:
     SmartLoader(MessageBroker& broker, IWebService& webService);  // TODO: add maxPreloadStorageSizeInBytes
 
-    virtual void HandleMessage(const IObservable& from, const IMessage& message);
+    virtual void HandleMessage(IObservable& from, const IMessage& message);
 
     void PreloadStudy(const std::string studyId);
     void PreloadSeries(const std::string seriesId);
--- a/Framework/Toolbox/IWebService.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Toolbox/IWebService.h	Wed Aug 22 15:08:15 2018 +0200
@@ -78,7 +78,7 @@
             {
             }
 
-            virtual void HandleMessage(const IObservable& from, const IMessage& message)
+            virtual void HandleMessage(IObservable& from, const IMessage& message)
             {
                 switch(message.GetType())
                 {
--- a/Framework/Toolbox/OrthancSlicesLoader.cpp	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Toolbox/OrthancSlicesLoader.cpp	Wed Aug 22 15:08:15 2018 +0200
@@ -271,7 +271,7 @@
     }
   };
   
-  void OrthancSlicesLoader::HandleMessage(const IObservable& from, const IMessage& message)
+  void OrthancSlicesLoader::HandleMessage(IObservable& from, const IMessage& message)
   {
     // forward messages to its own observers
     IObservable::broker_.EmitMessage(from, IObservable::observers_, message);
@@ -279,7 +279,7 @@
 
   
   void OrthancSlicesLoader::NotifySliceImageSuccess(const Operation& operation,
-                                                    std::auto_ptr<Orthanc::ImageAccessor>& image) const
+                                                    std::auto_ptr<Orthanc::ImageAccessor>& image)
   {
     if (image.get() == NULL)
     {
@@ -293,7 +293,7 @@
   }
   
   
-  void OrthancSlicesLoader::NotifySliceImageError(const Operation& operation) const
+  void OrthancSlicesLoader::NotifySliceImageError(const Operation& operation)
   {
     OrthancSlicesLoader::SliceImageErrorMessage msg(operation.GetSliceIndex(), operation.GetSlice(), operation.GetQuality());
     EmitMessage(msg);
--- a/Framework/Toolbox/OrthancSlicesLoader.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Toolbox/OrthancSlicesLoader.h	Wed Aug 22 15:08:15 2018 +0200
@@ -98,9 +98,9 @@
     SlicesSorter  slices_;
 
     void NotifySliceImageSuccess(const Operation& operation,
-                                 std::auto_ptr<Orthanc::ImageAccessor>& image) const;
+                                 std::auto_ptr<Orthanc::ImageAccessor>& image);
   
-    void NotifySliceImageError(const Operation& operation) const;
+    void NotifySliceImageError(const Operation& operation);
     
     void ParseSeriesGeometry(const void* answer,
                              size_t size);
@@ -166,6 +166,6 @@
     void ScheduleLoadSliceImage(size_t index,
                                 SliceImageQuality requestedQuality);
 
-    virtual void HandleMessage(const IObservable& from, const IMessage& message);
+    virtual void HandleMessage(IObservable& from, const IMessage& message);
   };
 }
--- a/Framework/Widgets/LayerWidget.cpp	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Widgets/LayerWidget.cpp	Wed Aug 22 15:08:15 2018 +0200
@@ -490,7 +490,7 @@
     }
   }
 
-  void LayerWidget::HandleMessage(const IObservable& from, const IMessage& message)
+  void LayerWidget::HandleMessage(IObservable& from, const IMessage& message)
   {
     switch (message.GetType()) {
     case MessageType_LayerSource_GeometryReady:
--- a/Framework/Widgets/LayerWidget.h	Wed Aug 22 14:59:20 2018 +0200
+++ b/Framework/Widgets/LayerWidget.h	Wed Aug 22 15:08:15 2018 +0200
@@ -73,7 +73,7 @@
   public:
     LayerWidget(MessageBroker& broker);
 
-    virtual void HandleMessage(const IObservable& from, const IMessage& message);
+    virtual void HandleMessage(IObservable& from, const IMessage& message);
 
     virtual Extent2D GetSceneExtent();
 
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Wed Aug 22 14:59:20 2018 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Wed Aug 22 15:08:15 2018 +0200
@@ -204,6 +204,7 @@
   ${ORTHANC_STONE_ROOT}/Framework/Toolbox/FiniteProjectiveCamera.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Toolbox/GeometryToolbox.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Toolbox/ImageGeometry.cpp
+  ${ORTHANC_STONE_ROOT}/Framework/Toolbox/IWebService.h
   ${ORTHANC_STONE_ROOT}/Framework/Toolbox/LinearAlgebra.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Toolbox/MessagingToolbox.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Toolbox/OrientedBoundingBox.cpp
--- a/UnitTestsSources/TestMessageBroker.cpp	Wed Aug 22 14:59:20 2018 +0200
+++ b/UnitTestsSources/TestMessageBroker.cpp	Wed Aug 22 15:08:15 2018 +0200
@@ -42,7 +42,7 @@
   }
 
 
-  void HandleMessage(const OrthancStone::IObservable& from, const OrthancStone::IMessage& message) {
+  void HandleMessage(OrthancStone::IObservable& from, const OrthancStone::IMessage& message) {
     switch (message.GetType())
     {
     case OrthancStone::MessageType_Test1:
@@ -70,7 +70,7 @@
   }
 
 
-  void HandleMessage(const OrthancStone::IObservable& from, const OrthancStone::IMessage& message) {
+  void HandleMessage(OrthancStone::IObservable& from, const OrthancStone::IMessage& message) {
     switch (message.GetType())
     {
     case OrthancStone::MessageType_Test1: