changeset 317:b66d13708f40 am-2

cleanup
author am@osimis.io
date Fri, 05 Oct 2018 11:57:36 +0200
parents aad37d0b6407
children 3a4ca166fafa
files Applications/Samples/SimpleViewerApplication.h Framework/Messages/IObservable.h Framework/Messages/MessageForwarder.h Framework/SmartLoader.cpp Framework/SmartLoader.h
diffstat 5 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/SimpleViewerApplication.h	Fri Oct 05 10:38:16 2018 +0200
+++ b/Applications/Samples/SimpleViewerApplication.h	Fri Oct 05 11:57:36 2018 +0200
@@ -279,8 +279,10 @@
           mainLayout_->AddWidget(thumbnailsLayout_);
           mainLayout_->AddWidget(mainWidget_);
 
+          orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService()));
+
           // sources
-          smartLoader_.reset(new SmartLoader(IObserver::broker_, context_->GetWebService()));
+          smartLoader_.reset(new SmartLoader(IObserver::broker_, *orthancApiClient_));
           smartLoader_->SetImageQuality(SliceImageQuality_FullPam);
 
           mainLayout_->SetTransmitMouseOver(true);
@@ -292,7 +294,6 @@
         statusBar.SetMessage("Use the key \"s\" to reinitialize the layout");
         statusBar.SetMessage("Use the key \"n\" to go to next image in the main viewport");
 
-        orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService()));
 
         if (parameters.count("studyId") < 1)
         {
--- a/Framework/Messages/IObservable.h	Fri Oct 05 10:38:16 2018 +0200
+++ b/Framework/Messages/IObservable.h	Fri Oct 05 11:57:36 2018 +0200
@@ -71,7 +71,8 @@
       for (Forwarders::iterator it = forwarders_.begin();
            it != forwarders_.end(); ++it)
       {
-        broker_.Unregister(dynamic_cast<IObserver&>(**it));
+        IMessageForwarder* fw = *it;
+        broker_.Unregister(dynamic_cast<IObserver&>(*fw));
       }
     }
 
--- a/Framework/Messages/MessageForwarder.h	Fri Oct 05 10:38:16 2018 +0200
+++ b/Framework/Messages/MessageForwarder.h	Fri Oct 05 11:57:36 2018 +0200
@@ -31,12 +31,13 @@
 
   class IObservable;
 
-  class IMessageForwarder : public boost::noncopyable
+  class IMessageForwarder : public IObserver
   {
     IObservable& emitter_;
   public:
-    IMessageForwarder(IObservable& emitter)
-      : emitter_(emitter)
+    IMessageForwarder(MessageBroker& broker, IObservable& emitter)
+      : IObserver(broker),
+        emitter_(emitter)
     {}
     virtual ~IMessageForwarder() {}
 
@@ -64,14 +65,13 @@
    * B.RegisterObserverCallback(new Callable<C, A:MessageTyper>(*this, &B::MyCallback))   // where this is C
    */
   template<typename TMessage>
-  class MessageForwarder : public IMessageForwarder, public IObserver, public Callable<MessageForwarder<TMessage>, TMessage>
+  class MessageForwarder : public IMessageForwarder, public Callable<MessageForwarder<TMessage>, TMessage>
   {
   public:
     MessageForwarder(MessageBroker& broker,
                      IObservable& emitter // the object that will emit the messages to forward
                      )
-      : IMessageForwarder(emitter),
-        IObserver(broker),
+      : IMessageForwarder(broker, emitter),
         Callable<MessageForwarder<TMessage>, TMessage>(*this, &MessageForwarder::ForwardMessage)
     {
       RegisterForwarderInEmitter();
--- a/Framework/SmartLoader.cpp	Fri Oct 05 10:38:16 2018 +0200
+++ b/Framework/SmartLoader.cpp	Fri Oct 05 11:57:36 2018 +0200
@@ -25,12 +25,11 @@
 
 namespace OrthancStone
 {
-  SmartLoader::SmartLoader(MessageBroker& broker, IWebService& webService) :
+  SmartLoader::SmartLoader(MessageBroker& broker, OrthancApiClient& orthancApiClient) :
     IObservable(broker),
     IObserver(broker),
     imageQuality_(SliceImageQuality_FullPam),
-    webService_(webService),
-    orthancApiClient_(broker, webService)
+    orthancApiClient_(orthancApiClient)
   {
   }
 
--- a/Framework/SmartLoader.h	Fri Oct 05 10:38:16 2018 +0200
+++ b/Framework/SmartLoader.h	Fri Oct 05 11:57:36 2018 +0200
@@ -24,7 +24,6 @@
 
 #include "Layers/ILayerSource.h"
 #include "Messages/IObservable.h"
-#include "../Platforms/Generic/OracleWebService.h"
 #include "Toolbox/OrthancApiClient.h"
 
 namespace OrthancStone
@@ -32,13 +31,12 @@
   class SmartLoader : public IObservable, IObserver
   {
     SliceImageQuality     imageQuality_;
-    IWebService&          webService_;
-    OrthancApiClient      orthancApiClient_;
+    OrthancApiClient&     orthancApiClient_;
 
     int studyListRequest_;
 
   public:
-    SmartLoader(MessageBroker& broker, IWebService& webService);  // TODO: add maxPreloadStorageSizeInBytes
+    SmartLoader(MessageBroker& broker, OrthancApiClient& orthancApiClient);  // TODO: add maxPreloadStorageSizeInBytes
 
     void PreloadStudy(const std::string studyId);
     void PreloadSeries(const std::string seriesId);