浏览代码

Extends ctkDicomAbstract{Host,App} with publishData convenient method

Each one of these class also expose a objectLocatorCache() method.

This method allows to fill the cache with data that will be publish at a
later time.
Jean-Christophe Fillion-Robin 14 年之前
父节点
当前提交
38bbae61b4

+ 35 - 7
Plugins/org.commontk.dah.app/ctkDicomAbstractApp.cpp

@@ -22,6 +22,7 @@
 // CTK includes
 #include "ctkDicomAbstractApp.h"
 #include <ctkDicomHostInterface.h>
+#include <ctkDicomObjectLocatorCache.h>
 #include <ctkPluginContext.h>
 #include <ctkServiceTracker.h>
 
@@ -29,10 +30,11 @@ class ctkDicomAbstractAppPrivate
 {
 public:
   ctkDicomAbstractAppPrivate(ctkPluginContext* context);
-  ~ctkDicomAbstractAppPrivate();
 
   ctkServiceTracker<ctkDicomHostInterface*> HostTracker;
   ctkDicomAppHosting::State currentState;
+
+  ctkDicomObjectLocatorCache ObjectLocatorCache;
 };
 
 //----------------------------------------------------------------------------
@@ -45,11 +47,6 @@ ctkDicomAbstractAppPrivate::ctkDicomAbstractAppPrivate(ctkPluginContext * contex
 }
 
 //----------------------------------------------------------------------------
-ctkDicomAbstractAppPrivate::~ctkDicomAbstractAppPrivate()
-{
-}
-
-//----------------------------------------------------------------------------
 // ctkDicomAbstractApp methods
 
 //----------------------------------------------------------------------------
@@ -145,7 +142,7 @@ bool ctkDicomAbstractApp::setState(ctkDicomAppHosting::State newState)
   return result;
 }
 
-
+//----------------------------------------------------------------------------
 ctkDicomHostInterface* ctkDicomAbstractApp::getHostInterface() const
 {
   ctkDicomHostInterface* host = d_ptr->HostTracker.getService();
@@ -153,4 +150,35 @@ ctkDicomHostInterface* ctkDicomAbstractApp::getHostInterface() const
   return host;
 }
 
+//----------------------------------------------------------------------------
+QList<ctkDicomAppHosting::ObjectLocator> ctkDicomAbstractApp::getData(
+  const QList<QUuid>& objectUUIDs,
+  const QList<QString>& acceptableTransferSyntaxUIDs,
+  bool includeBulkData)
+{
+  return this->objectLocatorCache()->getData(objectUUIDs, acceptableTransferSyntaxUIDs, includeBulkData);
+}
+
+//----------------------------------------------------------------------------
+ctkDicomObjectLocatorCache* ctkDicomAbstractApp::objectLocatorCache()const
+{
+  Q_D(const ctkDicomAbstractApp);
+  return const_cast<ctkDicomObjectLocatorCache*>(&d->ObjectLocatorCache);
+}
+
+//----------------------------------------------------------------------------
+bool ctkDicomAbstractApp::publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData)
+{
+  if (!this->objectLocatorCache()->isCached(availableData))
+    {
+    return false;
+    }
+  bool success = this->getHostInterface()->notifyDataAvailable(availableData, lastData);
+  if(!success)
+    {
+    return false;
+    }
+  return true;
+}
+
 

+ 12 - 0
Plugins/org.commontk.dah.app/ctkDicomAbstractApp.h

@@ -29,6 +29,8 @@
 class ctkDicomAbstractAppPrivate;
 class ctkDicomHostInterface;
 class ctkPluginContext;
+class ctkDicomObjectLocatorCache;
+
 /**
   * Provides a basic implementation for an application app.
   *
@@ -45,7 +47,17 @@ public:
 
   ctkDicomAbstractApp(ctkPluginContext* context);
   virtual ~ctkDicomAbstractApp();
+
   virtual bool setState(ctkDicomAppHosting::State newState);
+  
+  virtual QList<ctkDicomAppHosting::ObjectLocator> getData(
+    const QList<QUuid>& objectUUIDs,
+    const QList<QString>& acceptableTransferSyntaxUIDs,
+    bool includeBulkData);
+
+  ctkDicomObjectLocatorCache* objectLocatorCache()const;
+
+  bool publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData);
 
 protected:
   virtual ctkDicomHostInterface* getHostInterface() const;

+ 2 - 2
Plugins/org.commontk.dah.core/ctkDicomExchangeInterface.h

@@ -25,10 +25,10 @@
 
 #include <QRect>
 #include <QObject>
-#include <QUuid>
-
 #include "ctkDicomAppHostingTypes.h"
 
+class QUuid;
+
 struct ctkDicomExchangeInterface
 {
 

+ 1 - 0
Plugins/org.commontk.dah.core/ctkDicomObjectLocatorCache.cpp

@@ -20,6 +20,7 @@
 
 // Qt includes
 #include <QHash>
+#include <QUuid>
 
 // CTK includes
 #include "ctkDicomAppHostingTypes.h"

+ 1 - 0
Plugins/org.commontk.dah.core/ctkDicomObjectLocatorCache.h

@@ -29,6 +29,7 @@
 #include <org_commontk_dah_core_Export.h>
 
 class ctkDicomObjectLocatorCachePrivate;
+class QUuid;
 
 /**
   *

+ 4 - 0
Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppLogic_p.h

@@ -23,6 +23,10 @@
 #ifndef CTKEXAMPLEDICOMAPPLOGIC_P_H
 #define CTKEXAMPLEDICOMAPPLOGIC_P_H
 
+// Qt includes
+#include <QUuid>
+
+// CTK includes
 #include <ctkDicomAbstractApp.h>
 #include <ctkDicomHostInterface.h>
 

+ 40 - 6
Plugins/org.commontk.dah.host/ctkDicomAbstractHost.cpp

@@ -19,9 +19,11 @@
 
 =============================================================================*/
 
+// CTK includes
+#include "ctkDicomAppService.h"
 #include "ctkDicomAbstractHost.h"
 #include "ctkDicomHostServer.h"
-#include "ctkDicomAppService.h"
+#include <ctkDicomObjectLocatorCache.h>
 
 class ctkDicomAbstractHostPrivate
 {
@@ -34,6 +36,7 @@ public:
   int AppPort;
   ctkDicomHostServer* Server;
   ctkDicomAppInterface* AppService;
+  ctkDicomObjectLocatorCache ObjectLocatorCache;
   // ctkDicomAppHosting::Status
 };
 
@@ -45,11 +48,11 @@ ctkDicomAbstractHostPrivate::ctkDicomAbstractHostPrivate(
   ctkDicomAbstractHost* hostInterface, int hostPort, int appPort) : HostPort(hostPort), AppPort(appPort)
 {
   // start server
-  if (this->HostPort==0)
+  if (this->HostPort == 0)
     {
     this->HostPort = 8080;
     }
-  if (this->AppPort==0)
+  if (this->AppPort == 0)
     {
     this->AppPort = 8081;
     }
@@ -78,6 +81,11 @@ ctkDicomAbstractHost::ctkDicomAbstractHost(int hostPort, int appPort) :
 }
 
 //----------------------------------------------------------------------------
+ctkDicomAbstractHost::~ctkDicomAbstractHost()
+{
+}
+
+//----------------------------------------------------------------------------
 int ctkDicomAbstractHost::getHostPort() const
 {
   Q_D(const ctkDicomAbstractHost);
@@ -92,13 +100,39 @@ int ctkDicomAbstractHost::getAppPort() const
 }
 
 //----------------------------------------------------------------------------
-ctkDicomAbstractHost::~ctkDicomAbstractHost()
+ctkDicomAppInterface* ctkDicomAbstractHost::getDicomAppService() const
 {
+  Q_D(const ctkDicomAbstractHost);
+  return d->AppService;
 }
 
 //----------------------------------------------------------------------------
-ctkDicomAppInterface* ctkDicomAbstractHost::getDicomAppService() const
+QList<ctkDicomAppHosting::ObjectLocator> ctkDicomAbstractHost::getData(
+  const QList<QUuid>& objectUUIDs,
+  const QList<QString>& acceptableTransferSyntaxUIDs,
+  bool includeBulkData)
+{
+  return this->objectLocatorCache()->getData(objectUUIDs, acceptableTransferSyntaxUIDs, includeBulkData);
+}
+
+//----------------------------------------------------------------------------
+ctkDicomObjectLocatorCache* ctkDicomAbstractHost::objectLocatorCache()const
 {
   Q_D(const ctkDicomAbstractHost);
-  return d->AppService;
+  return const_cast<ctkDicomObjectLocatorCache*>(&d->ObjectLocatorCache);
+}
+
+//----------------------------------------------------------------------------
+bool ctkDicomAbstractHost::publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData)
+{
+  if (!this->objectLocatorCache()->isCached(availableData))
+    {
+    return false;
+    }
+  bool success = this->getDicomAppService()->notifyDataAvailable(availableData, lastData);
+  if(!success)
+    {
+    return false;
+    }
+  return true;
 }

+ 12 - 1
Plugins/org.commontk.dah.host/ctkDicomAbstractHost.h

@@ -29,6 +29,7 @@
 #include <org_commontk_dah_host_Export.h>
 
 class ctkDicomAbstractHostPrivate;
+class ctkDicomObjectLocatorCache;
 
 /**
   * Provides a basic implementation for an application host.
@@ -48,12 +49,22 @@ public:
     * Starts the soap sever on the specified port or choose port automatically.
     */
   ctkDicomAbstractHost(int hostPort = 0, int appPort = 0);
+  virtual ~ctkDicomAbstractHost();
   int getHostPort() const;
+
   int getAppPort() const;
-  virtual ~ctkDicomAbstractHost();
 
   ctkDicomAppInterface* getDicomAppService() const;
 
+  virtual QList<ctkDicomAppHosting::ObjectLocator> getData(
+    const QList<QUuid>& objectUUIDs,
+    const QList<QString>& acceptableTransferSyntaxUIDs,
+    bool includeBulkData);
+
+  ctkDicomObjectLocatorCache* objectLocatorCache()const;
+
+  bool publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData);
+
 private:
 
   Q_DECLARE_PRIVATE(ctkDicomAbstractHost)