Browse Source

Unified data exchange implementation for host/hosted part

Ivo Wolf 13 years ago
parent
commit
a45c6e5ce1

+ 1 - 0
Plugins/org.commontk.dah.core/CMakeLists.txt

@@ -5,6 +5,7 @@ PROJECT(org_commontk_dah_core)
 SET(PLUGIN_export_directive "org_commontk_dah_core_EXPORT")
 
 SET(PLUGIN_SRCS
+  ctkDicomAbstractExchangeCache.cpp
   ctkDicomAppHostingCorePlugin.cpp
   ctkDicomAppHostingCorePlugin_p.h
   ctkDicomAppHostingTypes.cpp

+ 105 - 0
Plugins/org.commontk.dah.core/ctkDicomAbstractExchangeCache.cpp

@@ -0,0 +1,105 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+// CTK includes
+#include "ctkDicomAbstractExchangeCache.h"
+#include "ctkDicomAppHostingTypesHelper.h"
+#include <ctkDicomObjectLocatorCache.h>
+
+class ctkDicomAbstractExchangeCachePrivate
+{
+public:
+
+  ctkDicomAbstractExchangeCachePrivate();
+  ~ctkDicomAbstractExchangeCachePrivate();
+
+  ctkDicomObjectLocatorCache ObjectLocatorCache;
+};
+
+//----------------------------------------------------------------------------
+// ctkDicomAbstractExchangeCachePrivate methods
+
+//----------------------------------------------------------------------------
+ctkDicomAbstractExchangeCachePrivate::ctkDicomAbstractExchangeCachePrivate()
+{
+
+}
+
+//----------------------------------------------------------------------------
+ctkDicomAbstractExchangeCachePrivate::~ctkDicomAbstractExchangeCachePrivate()
+{
+
+}
+
+//----------------------------------------------------------------------------
+// ctkDicomAbstractExchangeCache methods
+
+//----------------------------------------------------------------------------
+ctkDicomAbstractExchangeCache::ctkDicomAbstractExchangeCache() :
+  d_ptr(new ctkDicomAbstractExchangeCachePrivate)
+{
+
+}
+
+//----------------------------------------------------------------------------
+ctkDicomAbstractExchangeCache::~ctkDicomAbstractExchangeCache()
+{
+}
+
+//----------------------------------------------------------------------------
+QList<ctkDicomAppHosting::ObjectLocator> ctkDicomAbstractExchangeCache::getData(
+  const QList<QUuid>& objectUUIDs,
+  const QList<QUuid>& acceptableTransferSyntaxUIDs,
+  bool includeBulkData)
+{
+  Q_UNUSED(acceptableTransferSyntaxUIDs);
+  Q_UNUSED(includeBulkData);
+  return this->objectLocatorCache()->getData(objectUUIDs);
+}
+
+//----------------------------------------------------------------------------
+ctkDicomObjectLocatorCache* ctkDicomAbstractExchangeCache::objectLocatorCache()const
+{
+  Q_D(const ctkDicomAbstractExchangeCache);
+  return const_cast<ctkDicomObjectLocatorCache*>(&d->ObjectLocatorCache);
+}
+
+//----------------------------------------------------------------------------
+bool ctkDicomAbstractExchangeCache::publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData)
+{
+  if (!this->objectLocatorCache()->isCached(availableData))
+  {
+    return false;
+  }
+  bool success = this->getOtherSideExchangeService()->notifyDataAvailable(availableData, lastData);
+  if(!success)
+  {
+    return false;
+  }
+  return true;
+}
+
+//----------------------------------------------------------------------------
+void ctkDicomAbstractExchangeCache::releaseData(const QList<QUuid>& objectUUIDs)
+{
+  Q_UNUSED(objectUUIDs)
+}
+

+ 108 - 0
Plugins/org.commontk.dah.core/ctkDicomAbstractExchangeCache.h

@@ -0,0 +1,108 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef CTKDICOMABSTRACTEXCHANGECACHE_H
+#define CTKDICOMABSTRACTEXCHANGECACHE_H
+
+#include <ctkDicomExchangeInterface.h>
+#include <QScopedPointer>
+
+#include <org_commontk_dah_core_Export.h>
+
+class ctkDicomAbstractExchangeCachePrivate;
+class ctkDicomObjectLocatorCache;
+
+/**
+ * @brief Provides a basic convenience methods for the data exchange.
+ *
+ * The implementation is based on the ctkDicomObjectLocatorCache.
+*/
+class org_commontk_dah_core_EXPORT ctkDicomAbstractExchangeCache : public QObject, public virtual ctkDicomExchangeInterface
+{
+ //Q_OBJECT
+ Q_INTERFACES(ctkDicomExchangeInterface)
+
+public:
+
+  /**
+   * @brief Construct object.
+   *
+   * @param exchangeService the ctkDicomExchangeService of the other side.
+  */
+  ctkDicomAbstractExchangeCache();
+
+  /**
+   * @brief Destructor
+   *
+  */
+  virtual ~ctkDicomAbstractExchangeCache();
+
+  /**
+   * @brief Gets the exchange service of the other side.
+   *
+   * If we are a host, this must return the exchange service
+   * of the hosted app and vice versa.
+   *
+   * @return ctkDicomExchangeService * of the other side
+  */
+  virtual ctkDicomExchangeInterface* getOtherSideExchangeService() const = 0;
+
+  /**
+   * @brief Provide ctkDicomAppHosting::ObjectLocators to the other side.
+   *
+   * If we are a host, the other side is the hosted app and vice versa.
+   *
+   * @param objectUUIDs
+   * @param acceptableTransferSyntaxUIDs
+   * @param includeBulkData
+   * @return QList<ctkDicomAppHosting::ObjectLocator>
+  */
+  virtual QList<ctkDicomAppHosting::ObjectLocator> getData(
+    const QList<QUuid>& objectUUIDs,
+    const QList<QUuid>& acceptableTransferSyntaxUIDs,
+    bool includeBulkData);
+
+  void releaseData(const QList<QUuid>& objectUUIDs);
+
+  /**
+   * @brief
+   *
+   * @return ctkDicomObjectLocatorCache *
+  */
+  ctkDicomObjectLocatorCache* objectLocatorCache() const;
+
+  /**
+   * @brief
+   *
+   * @param availableData
+   * @param lastData
+   * @return bool
+  */
+  bool publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData);
+
+private:
+
+  Q_DECLARE_PRIVATE(ctkDicomAbstractExchangeCache)
+  const QScopedPointer<ctkDicomAbstractExchangeCachePrivate> d_ptr; /**< TODO */
+
+};
+
+#endif // CTKDICOMABSTRACTEXCHANGECACHE_H

+ 1 - 1
Plugins/org.commontk.dah.core/ctkDicomAppInterface.h

@@ -26,7 +26,7 @@
 #include "ctkDicomExchangeInterface.h"
 #include <ctkDicomAppHostingTypesHelper.h>
 
-struct ctkDicomAppInterface : public ctkDicomExchangeInterface
+struct ctkDicomAppInterface : public virtual ctkDicomExchangeInterface
 {
 
   // Application interface methods

+ 1 - 1
Plugins/org.commontk.dah.core/ctkDicomHostInterface.h

@@ -25,7 +25,7 @@
 
 #include "ctkDicomExchangeInterface.h"
 
-struct ctkDicomHostInterface: public ctkDicomExchangeInterface
+struct ctkDicomHostInterface : public virtual ctkDicomExchangeInterface
 {
   // Host interface methods
 

+ 0 - 6
Plugins/org.commontk.dah.examplehost/ctkExampleDicomHost.cpp

@@ -178,12 +178,6 @@ void ctkExampleDicomHost::onReleaseAvailableResources()
 }
 
 //----------------------------------------------------------------------------
-void ctkExampleDicomHost::releaseData(const QList<QUuid>& objectUUIDs)
-{
-  Q_UNUSED(objectUUIDs)
-}
-
-//----------------------------------------------------------------------------
 void ctkExampleDicomHost::exitApplication()
 {
   this->exitingApplication=true;

+ 0 - 6
Plugins/org.commontk.dah.examplehost/ctkExampleDicomHost.h

@@ -79,12 +79,6 @@ public:
    */
   virtual bool notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData);
 
-  /**
-   * The recipient of data invokes this method to release access to binary data provided by the source of the
-   * data through a getData() call. The ArrayOfUUID identifies the data streams that the recipient is releasing.
-   */
-  virtual void releaseData(const QList<QUuid>& objectUUIDs);
-
   ctkDicomAppHosting::State getApplicationState() const;
 
   const QProcess& getAppProcess() const { return this->AppProcess; }

+ 3 - 32
Plugins/org.commontk.dah.host/ctkDicomAbstractHost.cpp

@@ -39,7 +39,6 @@ public:
   ctkDicomHostServer* Server;
   ctkDicomAppInterface* AppService;
   ctkDicomAppHosting::State AppState;
-  ctkDicomObjectLocatorCache ObjectLocatorCache;
   // ctkDicomAppHosting::Status
 
 };
@@ -49,7 +48,7 @@ public:
 
 //----------------------------------------------------------------------------
 ctkDicomAbstractHostPrivate::ctkDicomAbstractHostPrivate(
-  ctkDicomAbstractHost* hostInterface, int hostPort, int appPort) : HostPort(hostPort), AppPort(appPort),AppState(ctkDicomAppHosting::EXIT)
+  ctkDicomAbstractHost* hostInterface, int hostPort, int appPort) : HostPort(hostPort), AppPort(appPort), AppState(ctkDicomAppHosting::EXIT)
 {
   // start server
   if (this->HostPort == 0)
@@ -82,7 +81,6 @@ ctkDicomAbstractHostPrivate::~ctkDicomAbstractHostPrivate()
 ctkDicomAbstractHost::ctkDicomAbstractHost(int hostPort, int appPort) :
   d_ptr(new ctkDicomAbstractHostPrivate(this, hostPort, appPort))
 {
-
 }
 
 //----------------------------------------------------------------------------
@@ -112,36 +110,9 @@ ctkDicomAppInterface* ctkDicomAbstractHost::getDicomAppService() const
 }
 
 //----------------------------------------------------------------------------
-QList<ctkDicomAppHosting::ObjectLocator> ctkDicomAbstractHost::getData(
-  const QList<QUuid>& objectUUIDs,
-  const QList<QUuid>& acceptableTransferSyntaxUIDs,
-  bool includeBulkData)
-{
-  Q_UNUSED(acceptableTransferSyntaxUIDs);
-  Q_UNUSED(includeBulkData);
-  return this->objectLocatorCache()->getData(objectUUIDs);
-}
-
-//----------------------------------------------------------------------------
-ctkDicomObjectLocatorCache* ctkDicomAbstractHost::objectLocatorCache()const
-{
-  Q_D(const ctkDicomAbstractHost);
-  return const_cast<ctkDicomObjectLocatorCache*>(&d->ObjectLocatorCache);
-}
-
-//----------------------------------------------------------------------------
-bool ctkDicomAbstractHost::publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData)
+ctkDicomExchangeInterface* ctkDicomAbstractHost::getOtherSideExchangeService() const
 {
-  if (!this->objectLocatorCache()->isCached(availableData))
-  {
-    return false;
-  }
-  bool success = this->getDicomAppService()->notifyDataAvailable(availableData, lastData);
-  if(!success)
-  {
-    return false;
-  }
-  return true;
+  return getDicomAppService();
 }
 
 //----------------------------------------------------------------------------

+ 8 - 29
Plugins/org.commontk.dah.host/ctkDicomAbstractHost.h

@@ -22,6 +22,7 @@
 #ifndef CTKDICOMABSTRACTHOST_H
 #define CTKDICOMABSTRACTHOST_H
 
+#include <ctkDicomAbstractExchangeCache.h>
 #include <ctkDicomHostInterface.h>
 #include <ctkDicomAppInterface.h>
 #include <QScopedPointer>
@@ -31,6 +32,11 @@
 class ctkDicomAbstractHostPrivate;
 class ctkDicomObjectLocatorCache;
 
+#ifdef _MSC_VER
+// disable inheritance by dominance warnings
+#pragma warning( disable : 4250 )
+#endif
+
 /**
  * @brief Provides a basic implementation for an application host.
  *
@@ -40,7 +46,7 @@ class ctkDicomObjectLocatorCache;
  * The methods of the ctkDicomHostInterface have to be implemented for the business logic,
  *
 */
-class org_commontk_dah_host_EXPORT ctkDicomAbstractHost : public QObject, public ctkDicomHostInterface
+class org_commontk_dah_host_EXPORT ctkDicomAbstractHost : public ctkDicomAbstractExchangeCache, public ctkDicomHostInterface
 {
  Q_OBJECT
  Q_INTERFACES(ctkDicomHostInterface)
@@ -102,34 +108,7 @@ public:
   */
   ctkDicomAppInterface* getDicomAppService() const;
 
-  /**
-   * @brief Gets ctkDicomAppHosting::ObjectLocators from the hosted app.
-   *
-   * @param objectUUIDs
-   * @param acceptableTransferSyntaxUIDs
-   * @param includeBulkData
-   * @return QList<ctkDicomAppHosting::ObjectLocator>
-  */
-  virtual QList<ctkDicomAppHosting::ObjectLocator> getData(
-    const QList<QUuid>& objectUUIDs,
-    const QList<QUuid>& acceptableTransferSyntaxUIDs,
-    bool includeBulkData);
-
-  /**
-   * @brief
-   *
-   * @return ctkDicomObjectLocatorCache *
-  */
-  ctkDicomObjectLocatorCache* objectLocatorCache() const;
-
-  /**
-   * @brief
-   *
-   * @param availableData
-   * @param lastData
-   * @return bool
-  */
-  bool publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData);
+  ctkDicomExchangeInterface* getOtherSideExchangeService() const;
 
 signals:
   /**

+ 6 - 33
Plugins/org.commontk.dah.hostedapp/ctkDicomAbstractApp.cpp

@@ -147,45 +147,18 @@ ctkDicomHostInterface* ctkDicomAbstractApp::getHostInterface() const
 }
 
 //----------------------------------------------------------------------------
-ctkDicomAppHosting::State ctkDicomAbstractApp::getState()
-{
-  return d_ptr->currentState;
-}
-
-void ctkDicomAbstractApp::setInternalState(ctkDicomAppHosting::State state)
-{
-  d_ptr->currentState = state;
-}
-
-//----------------------------------------------------------------------------
-QList<ctkDicomAppHosting::ObjectLocator> ctkDicomAbstractApp::getData(
-  const QList<QUuid>& objectUUIDs,
-  const QList<QUuid>& acceptableTransferSyntaxUIDs,
-  bool includeBulkData)
+ctkDicomExchangeInterface* ctkDicomAbstractApp::getOtherSideExchangeService() const
 {
-  Q_UNUSED(acceptableTransferSyntaxUIDs);
-  Q_UNUSED(includeBulkData);
-  return this->objectLocatorCache()->getData(objectUUIDs);
+  return getHostInterface();
 }
 
 //----------------------------------------------------------------------------
-ctkDicomObjectLocatorCache* ctkDicomAbstractApp::objectLocatorCache()const
+ctkDicomAppHosting::State ctkDicomAbstractApp::getState()
 {
-  Q_D(const ctkDicomAbstractApp);
-  return const_cast<ctkDicomObjectLocatorCache*>(&d->ObjectLocatorCache);
+  return d_ptr->currentState;
 }
 
-//----------------------------------------------------------------------------
-bool ctkDicomAbstractApp::publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData)
+void ctkDicomAbstractApp::setInternalState(ctkDicomAppHosting::State state)
 {
-  if (!this->objectLocatorCache()->isCached(availableData))
-    {
-    return false;
-    }
-  bool success = this->getHostInterface()->notifyDataAvailable(availableData, lastData);
-  if(!success)
-    {
-    return false;
-    }
-  return true;
+  d_ptr->currentState = state;
 }

+ 9 - 30
Plugins/org.commontk.dah.hostedapp/ctkDicomAbstractApp.h

@@ -22,6 +22,7 @@
 #ifndef CTKDICOMABSTRACTAPP_H
 #define CTKDICOMABSTRACTAPP_H
 
+#include <ctkDicomAbstractExchangeCache.h>
 #include <ctkDicomAppInterface.h>
 #include <QScopedPointer>
 #include <org_commontk_dah_hostedapp_Export.h>
@@ -31,6 +32,11 @@ struct ctkDicomHostInterface;
 class ctkPluginContext;
 class ctkDicomObjectLocatorCache;
 
+#ifdef _MSC_VER
+// disable inheritance by dominance warnings
+#pragma warning( disable : 4250 )
+#endif
+
 /**
  * @brief Provides a basic implementation for an application app.
  *
@@ -40,7 +46,7 @@ class ctkDicomObjectLocatorCache;
  *
  *
 */
-class org_commontk_dah_hostedapp_EXPORT ctkDicomAbstractApp : public QObject, public ctkDicomAppInterface
+class org_commontk_dah_hostedapp_EXPORT ctkDicomAbstractApp : public ctkDicomAbstractExchangeCache, public ctkDicomAppInterface
 {
   Q_OBJECT
   Q_INTERFACES(ctkDicomAppInterface)
@@ -79,35 +85,6 @@ public:
   */
   virtual ctkDicomAppHosting::State getState();
 
-  /**
-   * @brief Gets ctkDicomAppHosting::ObjectLocators from the hosting system.
-   *
-   * @param objectUUIDs
-   * @param acceptableTransferSyntaxUIDs
-   * @param includeBulkData
-   * @return QList<ctkDicomAppHosting::ObjectLocator>
-  */
-  virtual QList<ctkDicomAppHosting::ObjectLocator> getData(
-    const QList<QUuid>& objectUUIDs,
-    const QList<QUuid>& acceptableTransferSyntaxUIDs,
-    bool includeBulkData);
-
-  /**
-   * @brief
-   *
-   * @return ctkDicomObjectLocatorCache *
-  */
-  ctkDicomObjectLocatorCache* objectLocatorCache()const;
-
-  /**
-   * @brief
-   *
-   * @param availableData
-   * @param lastData
-   * @return bool
-  */
-  bool publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData);
-
 protected:
   /**
    * @brief Gets a handle to the host, in order to call methods on it.
@@ -116,6 +93,8 @@ protected:
   */
   virtual ctkDicomHostInterface* getHostInterface() const;
 
+  ctkDicomExchangeInterface* getOtherSideExchangeService() const;
+
   /**
    * @brief Sets the internal representation of the current state.
    *