changeset 1060:e146743f6cdc broker

removing file MessageBroker.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Oct 2019 17:20:41 +0200
parents e713f1a99861
children 3e8f59cefec6
files Applications/Generic/NativeStoneApplicationContext.cpp Applications/Generic/NativeStoneApplicationContext.h Applications/StoneApplicationContext.h Framework/Deprecated/Toolbox/IDelayedCallExecutor.h Framework/Deprecated/Toolbox/IWebService.h Framework/Deprecated/Toolbox/OrthancApiClient.cpp Framework/Deprecated/Toolbox/OrthancApiClient.h Framework/Deprecated/Viewport/WidgetViewport.cpp Framework/Deprecated/Viewport/WidgetViewport.h Framework/Messages/IObserver.h Framework/Messages/MessageBroker.h Framework/Messages/MessageForwarder.h Framework/Scene2DViewport/AngleMeasureTool.cpp Framework/Scene2DViewport/AngleMeasureTool.h Framework/Scene2DViewport/CreateAngleMeasureCommand.cpp Framework/Scene2DViewport/CreateAngleMeasureCommand.h Framework/Scene2DViewport/CreateAngleMeasureTracker.cpp Framework/Scene2DViewport/CreateAngleMeasureTracker.h Framework/Scene2DViewport/CreateLineMeasureCommand.cpp Framework/Scene2DViewport/CreateLineMeasureCommand.h Framework/Scene2DViewport/CreateLineMeasureTracker.cpp Framework/Scene2DViewport/CreateLineMeasureTracker.h Framework/Scene2DViewport/LineMeasureTool.cpp Framework/Scene2DViewport/LineMeasureTool.h Framework/Scene2DViewport/MeasureTool.cpp Framework/Scene2DViewport/MeasureTool.h Resources/CMake/OrthancStoneConfiguration.cmake
diffstat 27 files changed, 26 insertions(+), 133 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Generic/NativeStoneApplicationContext.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Applications/Generic/NativeStoneApplicationContext.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -45,9 +45,7 @@
   }
   
 
-  NativeStoneApplicationContext::NativeStoneApplicationContext(MessageBroker& broker) :
-    StoneApplicationContext(broker),
-    centralViewport_(broker),
+  NativeStoneApplicationContext::NativeStoneApplicationContext() :
     stopped_(true),
     updateDelayInMs_(100)   // By default, 100ms between each refresh of the content
   {
--- a/Applications/Generic/NativeStoneApplicationContext.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Applications/Generic/NativeStoneApplicationContext.h	Fri Oct 11 17:20:41 2019 +0200
@@ -69,7 +69,7 @@
       }
     };
 
-    NativeStoneApplicationContext(MessageBroker& broker);
+    NativeStoneApplicationContext();
 
     void Start();
 
--- a/Applications/StoneApplicationContext.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Applications/StoneApplicationContext.h	Fri Oct 11 17:20:41 2019 +0200
@@ -59,7 +59,6 @@
   class StoneApplicationContext : public boost::noncopyable
   {
   private:
-    MessageBroker&                   broker_;
     Deprecated::IWebService*         webService_;
     Deprecated::IDelayedCallExecutor*            delayedCallExecutor_;
     std::auto_ptr<Deprecated::OrthancApiClient>  orthanc_;
@@ -68,8 +67,7 @@
     void InitializeOrthanc();
 
   public:
-    StoneApplicationContext(MessageBroker& broker) :
-      broker_(broker),
+    StoneApplicationContext() :
       webService_(NULL),
       delayedCallExecutor_(NULL)
     {
@@ -79,11 +77,6 @@
     {
     }
 
-    MessageBroker& GetMessageBroker()
-    {
-      return broker_;
-    }
-
     bool HasWebService() const
     {
       return webService_ != NULL;
--- a/Framework/Deprecated/Toolbox/IDelayedCallExecutor.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Deprecated/Toolbox/IDelayedCallExecutor.h	Fri Oct 11 17:20:41 2019 +0200
@@ -35,22 +35,12 @@
   // The IDelayedCall executes a callback after a delay (equivalent to timeout() function in javascript).
   class IDelayedCallExecutor : public boost::noncopyable
   {
-  protected:
-    OrthancStone::MessageBroker& broker_;
-    
   public:
     ORTHANC_STONE_DEFINE_EMPTY_MESSAGE(__FILE__, __LINE__, TimeoutMessage);
 
-    IDelayedCallExecutor(OrthancStone::MessageBroker& broker) :
-      broker_(broker)
-    {
-    }
-
-    
     virtual ~IDelayedCallExecutor()
     {
     }
-
     
     virtual void Schedule(OrthancStone::MessageHandler<IDelayedCallExecutor::TimeoutMessage>* callback,
                           unsigned int timeoutInMs = 1000) = 0;
--- a/Framework/Deprecated/Toolbox/IWebService.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Deprecated/Toolbox/IWebService.h	Fri Oct 11 17:20:41 2019 +0200
@@ -40,9 +40,6 @@
   // and you'll be notified when the response/error is ready.
   class IWebService : public boost::noncopyable
   {
-  protected:
-    OrthancStone::MessageBroker& broker_;
-    
   public:
     typedef std::map<std::string, std::string> HttpHeaders;
 
@@ -138,12 +135,6 @@
     };
 
 
-    IWebService(OrthancStone::MessageBroker& broker) :
-      broker_(broker)
-    {
-    }
-
-    
     virtual ~IWebService()
     {
     }
--- a/Framework/Deprecated/Toolbox/OrthancApiClient.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Deprecated/Toolbox/OrthancApiClient.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -73,7 +73,6 @@
     std::auto_ptr< OrthancStone::MessageHandler<BinaryResponseReadyMessage> >            binaryHandler_;
     std::auto_ptr< OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage> >  failureHandler_;
     std::auto_ptr< Orthanc::IDynamicObject >                               userPayload_;
-    OrthancStone::MessageBroker&                                                         broker_;
     void NotifyConversionError(const IWebService::HttpRequestSuccessMessage& message) const
     {
       if (failureHandler_.get() != NULL)
@@ -84,14 +83,12 @@
     }
     
   public:
-    WebServicePayload(OrthancStone::MessageBroker& broker,
-                      OrthancStone::MessageHandler<EmptyResponseReadyMessage>* handler,
+    WebServicePayload(OrthancStone::MessageHandler<EmptyResponseReadyMessage>* handler,
                       OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler,
                       Orthanc::IDynamicObject* userPayload) :
       emptyHandler_(handler),
       failureHandler_(failureHandler),
-      userPayload_(userPayload),
-      broker_(broker)
+      userPayload_(userPayload)
 
     {
       if (handler == NULL)
@@ -100,14 +97,12 @@
       }
     }
 
-    WebServicePayload(OrthancStone::MessageBroker& broker,
-                      OrthancStone::MessageHandler<BinaryResponseReadyMessage>* handler,
+    WebServicePayload(OrthancStone::MessageHandler<BinaryResponseReadyMessage>* handler,
                       OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler,
                       Orthanc::IDynamicObject* userPayload) :
       binaryHandler_(handler),
       failureHandler_(failureHandler),
-      userPayload_(userPayload),
-      broker_(broker)
+      userPayload_(userPayload)
     {
       if (handler == NULL)
       {
@@ -115,14 +110,12 @@
       }
     }
 
-    WebServicePayload(OrthancStone::MessageBroker& broker,
-                      OrthancStone::MessageHandler<JsonResponseReadyMessage>* handler,
+    WebServicePayload(OrthancStone::MessageHandler<JsonResponseReadyMessage>* handler,
                       OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureHandler,
                       Orthanc::IDynamicObject* userPayload) :
       jsonHandler_(handler),
       failureHandler_(failureHandler),
-      userPayload_(userPayload),
-      broker_(broker)
+      userPayload_(userPayload)
     {
       if (handler == NULL)
       {
--- a/Framework/Deprecated/Toolbox/OrthancApiClient.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Deprecated/Toolbox/OrthancApiClient.h	Fri Oct 11 17:20:41 2019 +0200
@@ -157,8 +157,7 @@
     std::string   baseUrl_;
 
   public:
-    OrthancApiClient(OrthancStone::MessageBroker& broker,
-                     IWebService& web,
+    OrthancApiClient(IWebService& web,
                      const std::string& baseUrl);
     
     virtual ~OrthancApiClient()
--- a/Framework/Deprecated/Viewport/WidgetViewport.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Deprecated/Viewport/WidgetViewport.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -26,8 +26,7 @@
 
 namespace Deprecated
 {
-  WidgetViewport::WidgetViewport(OrthancStone::MessageBroker& broker) :
-    IViewport(broker),
+  WidgetViewport::WidgetViewport() :
     statusBar_(NULL),
     isMouseOver_(false),
     lastMouseX_(0),
--- a/Framework/Deprecated/Viewport/WidgetViewport.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Deprecated/Viewport/WidgetViewport.h	Fri Oct 11 17:20:41 2019 +0200
@@ -41,7 +41,7 @@
     bool                          backgroundChanged_;
 
   public:
-    WidgetViewport(OrthancStone::MessageBroker& broker);
+    WidgetViewport();
 
     virtual void FitContent();
 
--- a/Framework/Messages/IObserver.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Messages/IObserver.h	Fri Oct 11 17:20:41 2019 +0200
@@ -26,8 +26,6 @@
 
 namespace OrthancStone 
 {
-  class MessageBroker;  // TODO - Remove
-
   class IObserver : public boost::noncopyable
   {
   public:
@@ -35,11 +33,6 @@
     {
     }
 
-    // TODO - Remove
-    IObserver(MessageBroker& broker)
-    {
-    }
-
     virtual ~IObserver()
     {
     }
--- a/Framework/Messages/MessageBroker.h	Fri Oct 11 17:08:34 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2019 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#pragma once
-
-#include <boost/noncopyable.hpp>
-
-namespace OrthancStone
-{
-  class IObserver;
-
-  /*
-   * This is a central message broker.  It keeps track of all observers and knows
-   * when an observer is deleted.
-   * This way, it can prevent an observable to send a message to a deleted observer.
-   */
-  class MessageBroker : public boost::noncopyable
-  {
-  public:
-    void Register(const IObserver& observer)
-    {
-    }
-
-    void Unregister(const IObserver& observer)
-    {
-    }
-
-    bool IsActive(const IObserver& observer)
-    {
-      return false;
-    }
-  };
-}
--- a/Framework/Messages/MessageForwarder.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Messages/MessageForwarder.h	Fri Oct 11 17:20:41 2019 +0200
@@ -35,9 +35,8 @@
   {
     IObservable& emitter_;
   public:
-    IMessageForwarder(MessageBroker& broker, IObservable& emitter)
-      : IObserver(broker),
-        emitter_(emitter)
+    IMessageForwarder(IObservable& emitter)
+      : emitter_(emitter)
     {}
     virtual ~IMessageForwarder() {}
 
@@ -68,10 +67,9 @@
   class MessageForwarder : public IMessageForwarder, public Callable<MessageForwarder<TMessage>, TMessage>
   {
   public:
-    MessageForwarder(MessageBroker& broker,
-                     IObservable& emitter // the object that will emit the messages to forward
+    MessageForwarder(IObservable& emitter // the object that will emit the messages to forward
                      )
-      : IMessageForwarder(broker, emitter),
+      : IMessageForwarder(emitter),
         Callable<MessageForwarder<TMessage>, TMessage>(*this, &MessageForwarder::ForwardMessage)
     {
       RegisterForwarderInEmitter();
--- a/Framework/Scene2DViewport/AngleMeasureTool.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/AngleMeasureTool.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -42,8 +42,8 @@
   // the params in the LayerHolder ctor specify the number of polyline and text
   // layers
   AngleMeasureTool::AngleMeasureTool(
-    MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW)
-    : MeasureTool(broker, controllerW)
+    boost::weak_ptr<ViewportController> controllerW)
+    : MeasureTool(controllerW)
 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
     , layerHolder_(boost::make_shared<LayerHolder>(controllerW,1,5))
 #else
--- a/Framework/Scene2DViewport/AngleMeasureTool.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/AngleMeasureTool.h	Fri Oct 11 17:20:41 2019 +0200
@@ -40,7 +40,7 @@
   class AngleMeasureTool : public MeasureTool
   {
   public:
-    AngleMeasureTool(MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW);
+    AngleMeasureTool(boost::weak_ptr<ViewportController> controllerW);
 
     ~AngleMeasureTool();
 
--- a/Framework/Scene2DViewport/CreateAngleMeasureCommand.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/CreateAngleMeasureCommand.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -26,12 +26,11 @@
 namespace OrthancStone
 {
   CreateAngleMeasureCommand::CreateAngleMeasureCommand(
-    MessageBroker& broker,
     boost::weak_ptr<ViewportController> controllerW,
     ScenePoint2D           point)
     : CreateMeasureCommand(controllerW)
     , measureTool_(
-      boost::make_shared<AngleMeasureTool>(boost::ref(broker), controllerW))
+      boost::make_shared<AngleMeasureTool>(controllerW))
   {
     GetController()->AddMeasureTool(measureTool_);
     measureTool_->SetSide1End(point);
--- a/Framework/Scene2DViewport/CreateAngleMeasureCommand.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/CreateAngleMeasureCommand.h	Fri Oct 11 17:20:41 2019 +0200
@@ -28,7 +28,6 @@
   public:
     /** Ctor sets end of side 1*/
     CreateAngleMeasureCommand(
-      MessageBroker& broker,
       boost::weak_ptr<ViewportController> controllerW,
       ScenePoint2D           point);
 
--- a/Framework/Scene2DViewport/CreateAngleMeasureTracker.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/CreateAngleMeasureTracker.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -26,7 +26,6 @@
 namespace OrthancStone
 {
   CreateAngleMeasureTracker::CreateAngleMeasureTracker(
-    MessageBroker&                  broker,
     boost::weak_ptr<ViewportController>          controllerW,
     const PointerEvent&             e)
     : CreateMeasureTracker(controllerW)
@@ -34,7 +33,6 @@
   {
     command_.reset(
       new CreateAngleMeasureCommand(
-        broker,
         controllerW,
         e.GetMainPosition().Apply(GetScene().GetCanvasToSceneTransform())));
   }
--- a/Framework/Scene2DViewport/CreateAngleMeasureTracker.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/CreateAngleMeasureTracker.h	Fri Oct 11 17:20:41 2019 +0200
@@ -38,7 +38,6 @@
     must be supplied, too
     */
     CreateAngleMeasureTracker(
-      MessageBroker&                  broker,
       boost::weak_ptr<ViewportController>          controllerW,
       const PointerEvent&             e);
 
--- a/Framework/Scene2DViewport/CreateLineMeasureCommand.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/CreateLineMeasureCommand.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -26,12 +26,11 @@
 namespace OrthancStone
 {
   CreateLineMeasureCommand::CreateLineMeasureCommand(
-    MessageBroker& broker,
     boost::weak_ptr<ViewportController> controllerW,
     ScenePoint2D           point)
     : CreateMeasureCommand(controllerW)
     , measureTool_(
-      boost::make_shared<LineMeasureTool>(boost::ref(broker), controllerW))
+      boost::make_shared<LineMeasureTool>(controllerW))
   {
     GetController()->AddMeasureTool(measureTool_);
     measureTool_->Set(point, point);
--- a/Framework/Scene2DViewport/CreateLineMeasureCommand.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/CreateLineMeasureCommand.h	Fri Oct 11 17:20:41 2019 +0200
@@ -27,7 +27,6 @@
   {
   public:
     CreateLineMeasureCommand(
-      MessageBroker& broker,
       boost::weak_ptr<ViewportController> controllerW,
       ScenePoint2D           point);
 
--- a/Framework/Scene2DViewport/CreateLineMeasureTracker.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/CreateLineMeasureTracker.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -26,14 +26,12 @@
 namespace OrthancStone
 {
   CreateLineMeasureTracker::CreateLineMeasureTracker(
-    MessageBroker&                  broker,
     boost::weak_ptr<ViewportController>          controllerW,
     const PointerEvent&             e)
     : CreateMeasureTracker(controllerW)
   {
     command_.reset(
       new CreateLineMeasureCommand(
-        broker,
         controllerW,
         e.GetMainPosition().Apply(GetScene().GetCanvasToSceneTransform())));
   }
--- a/Framework/Scene2DViewport/CreateLineMeasureTracker.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/CreateLineMeasureTracker.h	Fri Oct 11 17:20:41 2019 +0200
@@ -38,7 +38,6 @@
     must be supplied, too
     */
     CreateLineMeasureTracker(
-      MessageBroker&                  broker,
       boost::weak_ptr<ViewportController>          controllerW,
       const PointerEvent&             e);
 
--- a/Framework/Scene2DViewport/LineMeasureTool.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/LineMeasureTool.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -32,8 +32,8 @@
 {
 
   LineMeasureTool::LineMeasureTool(
-    MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW)
-    : MeasureTool(broker, controllerW)
+    boost::weak_ptr<ViewportController> controllerW)
+    : MeasureTool(controllerW)
 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
     , layerHolder_(boost::make_shared<LayerHolder>(controllerW, 1, 5))
 #else
--- a/Framework/Scene2DViewport/LineMeasureTool.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/LineMeasureTool.h	Fri Oct 11 17:20:41 2019 +0200
@@ -38,7 +38,7 @@
   class LineMeasureTool : public MeasureTool
   {
   public:
-    LineMeasureTool(MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW);
+    LineMeasureTool(boost::weak_ptr<ViewportController> controllerW);
 
     ~LineMeasureTool();
 
--- a/Framework/Scene2DViewport/MeasureTool.cpp	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/MeasureTool.cpp	Fri Oct 11 17:20:41 2019 +0200
@@ -79,7 +79,7 @@
 #endif
   }
 
-  MeasureTool::MeasureTool(MessageBroker& broker,
+  MeasureTool::MeasureTool(
     boost::weak_ptr<ViewportController> controllerW)
     : controllerW_(controllerW)
     , enabled_(true)
--- a/Framework/Scene2DViewport/MeasureTool.h	Fri Oct 11 17:08:34 2019 +0200
+++ b/Framework/Scene2DViewport/MeasureTool.h	Fri Oct 11 17:20:41 2019 +0200
@@ -111,7 +111,7 @@
     virtual std::string GetDescription() = 0;
 
   protected:
-    MeasureTool(MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW);
+    MeasureTool(boost::weak_ptr<ViewportController> controllerW);
 
     /**
     The measuring tool may exist in a standalone fashion, without any available
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Fri Oct 11 17:08:34 2019 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Fri Oct 11 17:20:41 2019 +0200
@@ -453,7 +453,6 @@
   ${ORTHANC_STONE_ROOT}/Framework/Messages/IMessage.h
   ${ORTHANC_STONE_ROOT}/Framework/Messages/IObservable.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Messages/IObserver.h
-  ${ORTHANC_STONE_ROOT}/Framework/Messages/MessageBroker.h
   ${ORTHANC_STONE_ROOT}/Framework/Messages/MessageForwarder.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Oracle/GetOrthancImageCommand.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Oracle/GetOrthancWebViewerJpegCommand.cpp