Преглед изворни кода

ENH+CHG dah added ExchangeService + *Service depends on ExchangeService

Benoît Bleuzé пре 15 година
родитељ
комит
43ef0def51

+ 6 - 7
Plugins/org.commontk.dicom.wg23.app/ctkDicomHostService.cpp

@@ -25,8 +25,8 @@
 
 #include "ctkDicomWG23TypesHelper.h"
 
-ctkDicomHostService::ctkDicomHostService(int port)
-  : d_ptr(new ctkDicomServicePrivate(port))
+ctkDicomHostService::ctkDicomHostService(ushort port):
+    ctkDicomExchangeService(port)
 {
 
 }
@@ -36,7 +36,7 @@ ctkDicomHostService::~ctkDicomHostService()
 
 QString ctkDicomHostService::generateUID()
 {
-  Q_D(ctkDicomService);
+  //Q_D(ctkDicomService);
 
   const QtSoapType& result = d->askHost("generateUID", NULL);
   QString resultUID = ctkDicomSoapUID::getUID(result);
@@ -45,7 +45,7 @@ QString ctkDicomHostService::generateUID()
 
 QString ctkDicomHostService::getOutputLocation(const QStringList& preferredProtocols)
 {
-  Q_D(ctkDicomService);
+  //Q_D(ctkDicomHostService);
 
   QtSoapStruct* input = dynamic_cast<QtSoapStruct*>(
     new ctkDicomSoapArrayOfString("preferredProtocols", preferredProtocols));
@@ -56,7 +56,7 @@ QString ctkDicomHostService::getOutputLocation(const QStringList& preferredProto
 
 QRect ctkDicomHostService::getAvailableScreen(const QRect& preferredScreen)
 {
-  Q_D(ctkDicomService);
+  //Q_D(ctkDicomService);
 
   QtSoapStruct* input = new ctkDicomSoapRectangle("preferredScreen", preferredScreen);
   const QtSoapType& result = d->askHost("getAvailableScreen", input);
@@ -75,8 +75,7 @@ void ctkDicomHostService::notifyStateChanged(ctkDicomWG23::State state)
 
 void ctkDicomHostService::notifyStatus(const ctkDicomWG23::Status& status)
 {
-  Q_D(ctkDicomService);
-
+  //Q_D(ctkDicomService);
   QtSoapStruct* input = new ctkDicomSoapStatus("status", status);
   d->askHost("notifyStatus", input);
 }

+ 5 - 6
Plugins/org.commontk.dicom.wg23.app/ctkDicomHostService.h

@@ -24,16 +24,16 @@
 #define CTKDICOMHOSTSERVICE_H
 
 #include <ctkDicomHostInterface.h>
-#include <QScopedPointer>
+#include <ctkDicomExchangeService.h>
 #include <org_commontk_dicom_wg23_app_Export.h>
 
-class ctkDicomServicePrivate;
 
-class org_commontk_dicom_wg23_app_EXPORT ctkDicomHostService : public ctkDicomHostInterface
+
+class org_commontk_dicom_wg23_app_EXPORT ctkDicomHostService : public ctkDicomExchangeService,public ctkDicomHostInterface
 {
 
 public:
-  ctkDicomHostService(int port);
+  ctkDicomHostService(ushort port);
   ~ctkDicomHostService();
 
   QString generateUID();
@@ -43,9 +43,8 @@ public:
   void notifyStatus(const ctkDicomWG23::Status& status);
 
 private:
-  Q_DECLARE_PRIVATE(ctkDicomService)
+  ctkDicomServicePrivate * d;
 
-  const QScopedPointer<ctkDicomServicePrivate> d_ptr;
 };
 
 #endif // CTKDICOMHOSTSERVICE_H

+ 3 - 1
Plugins/org.commontk.dicom.wg23.core/CMakeLists.txt

@@ -22,7 +22,8 @@ SET(PLUGIN_SRCS
   ctkDicomServicePrivate.cpp
   ctkDicomWG23Types.h
   ctkDicomWG23TypesHelper.h
-)
+  ctkDicomExchangeService.cpp
+  )
 
 # Files which should be processed by Qts moc
 SET(PLUGIN_MOC_SRCS
@@ -34,6 +35,7 @@ SET(PLUGIN_MOC_SRCS
   ctkDicomWG23CorePlugin_p.h
   ctkSimpleSoapServer.h
   ctkSoapConnectionRunnable_p.h
+  ctkDicomExchangeService.h
 )
 
 # Qt Designer files which should be processed by Qts uic

+ 1 - 1
Plugins/org.commontk.dicom.wg23.core/ctkDicomAppInterface.h

@@ -31,7 +31,7 @@
 
 #include <org_commontk_dicom_wg23_core_Export.h>
 
-class org_commontk_dicom_wg23_core_EXPORT ctkDicomAppInterface : public ctkDicomExchangeInterface
+class org_commontk_dicom_wg23_core_EXPORT ctkDicomAppInterface : public QObject
 {
   Q_OBJECT
 

+ 4 - 3
Plugins/org.commontk.dicom.wg23.core/ctkDicomExchangeInterface.h

@@ -27,7 +27,6 @@
 #include <QRect>
 
 #include "ctkDicomWG23Types.h"
-
 #include <org_commontk_dicom_wg23_core_Export.h>
 
 class org_commontk_dicom_wg23_core_EXPORT ctkDicomExchangeInterface : public QObject
@@ -39,13 +38,15 @@ public:
   // Data exchange interface methods
   //
 
-  //virtual bool notifyDataAvailable(ctkDicomWG23::AvailableData data, bool lastData) = 0;
-  //virtual QList<ctkDicomWG23::ObjectLocator> getData(QList<QUuid> objectUUIDs, QList<QString> acceptableTransferSyntaxUIDs, bool includeBulkData) = 0;
+  virtual bool notifyDataAvailable(ctkDicomWG23::AvailableData data, bool lastData)=0;
+
+  virtual QList<ctkDicomWG23::ObjectLocator> getData(QList<QUuid> objectUUIDs, QList<QString> acceptableTransferSyntaxUIDs, bool includeBulkData) = 0;
 
   //    8.3.3 getAsModels(objectUUIDs : ArrayOfUUID, classUID : UID, supportedInfosetTypes : ArrayOfMimeType) : ModelSetDescriptor	33
 //    8.3.4 queryModel(models : ArrayOfUUID, xpaths : ArrayOfString) : ArrayOfQueryResult	34
 //    8.3.5 queryInfoset(models : ArrayOfUUID, xpaths : ArrayOfString) : ArrayOfQueryResultInfoset	34
 //    8.3.6 releaseData(objectUUIDs : ArrayOfUUID): void	35
+  virtual void releaseData(QList<QUuid> objectUUIDs) = 0;
 //    8.3.7 releaseModels(objectUUIDs : ArrayOfUUID): void
 
   virtual ~ctkDicomExchangeInterface() {}

+ 60 - 0
Plugins/org.commontk.dicom.wg23.core/ctkDicomExchangeService.cpp

@@ -0,0 +1,60 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) 2010 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.
+
+=============================================================================*/
+
+#include "ctkDicomExchangeService.h"
+
+#include "ctkDicomServicePrivate.h"
+
+#include "ctkDicomWG23TypesHelper.h"
+
+ctkDicomExchangeService::ctkDicomExchangeService(ushort port)
+ : d(new ctkDicomServicePrivate(port))
+{
+
+}
+ctkDicomExchangeService::~ctkDicomExchangeService()
+{
+    delete d;
+    d = NULL;
+}
+
+bool ctkDicomExchangeService::notifyDataAvailable(
+        ctkDicomWG23::AvailableData data, bool lastData){
+    //Q_D(ctkDicomService);
+    QList<QtSoapType*> list;
+    list << new ctkDicomSoapAvailableData("data", data);
+    list << new ctkDicomSoapBool("lastData", lastData);
+    const QtSoapType & result = d->askHost("notifyDataAvailable",list);
+    return ctkDicomSoapBool::getBool(result);
+}
+
+QList<ctkDicomWG23::ObjectLocator> ctkDicomExchangeService::getData(
+        QList<QUuid> objectUUIDs,
+        QList<QString> acceptableTransferSyntaxUIDs, bool includeBulkData){
+    QList<ctkDicomWG23::ObjectLocator> ol;
+    return ol;
+}
+
+void ctkDicomExchangeService::releaseData(QList<QUuid> objectUUIDs){
+
+}
+
+

+ 48 - 0
Plugins/org.commontk.dicom.wg23.core/ctkDicomExchangeService.h

@@ -0,0 +1,48 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) 2010 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 CTKDICOMEXCHANGESERVICE_H
+#define CTKDICOMEXCHANGESERVICE_H
+
+#include <ctkDicomExchangeInterface.h>
+#include <QScopedPointer>
+#include <org_commontk_dicom_wg23_core_Export.h>
+
+class ctkDicomServicePrivate;
+
+class org_commontk_dicom_wg23_core_EXPORT ctkDicomExchangeService : public ctkDicomExchangeInterface
+{
+
+public:
+  ctkDicomExchangeService(ushort port);
+  ~ctkDicomExchangeService();
+
+  bool notifyDataAvailable(ctkDicomWG23::AvailableData data, bool lastData);
+  QList<ctkDicomWG23::ObjectLocator> getData(QList<QUuid> objectUUIDs,
+                                             QList<QString> acceptableTransferSyntaxUIDs, bool includeBulkData);
+  void releaseData(QList<QUuid> objectUUIDs);
+
+
+protected:
+  ctkDicomServicePrivate * d;
+};
+#endif // CTKDICOMEXCHANGESERVICE_H

+ 1 - 1
Plugins/org.commontk.dicom.wg23.core/ctkDicomHostInterface.h

@@ -31,7 +31,7 @@
 
 #include <org_commontk_dicom_wg23_core_Export.h>
 
-class org_commontk_dicom_wg23_core_EXPORT ctkDicomHostInterface : public ctkDicomExchangeInterface
+class org_commontk_dicom_wg23_core_EXPORT ctkDicomHostInterface: public QObject
 {
   Q_OBJECT
 

+ 16 - 4
Plugins/org.commontk.dicom.wg23.core/ctkDicomServicePrivate.cpp

@@ -40,7 +40,15 @@ void ctkDicomServicePrivate::responseReady()
   blockingLoop.exit();
 }
 
-const QtSoapType & ctkDicomServicePrivate::askHost(const QString& methodName, QtSoapType* soapType )
+const QtSoapType & ctkDicomServicePrivate::askHost(const QString& methodName,
+                                                   QtSoapType* soapType ){
+    QList<QtSoapType*> list;
+    list.append(soapType);
+    return askHost(methodName,list);
+}
+
+const QtSoapType & ctkDicomServicePrivate::askHost(const QString& methodName,
+                                                   const QList<QtSoapType*>& soapTypes )
 {
   qDebug() << "Submitting request " << methodName;
 
@@ -48,10 +56,14 @@ const QtSoapType & ctkDicomServicePrivate::askHost(const QString& methodName, Qt
 
   QtSoapMessage request;
   request.setMethod(methodName);
-  if( soapType != NULL )
+  if( !soapTypes.isEmpty())
   {
-    request.addMethodArgument(soapType);
-    qDebug() << "  Argument type is " << soapType->typeName();
+      for (QList<QtSoapType*>::ConstIterator it = soapTypes.begin();
+            it < soapTypes.constEnd(); it++){
+        request.addMethodArgument(*it);
+        qDebug() << "  Argument type added " << (*it)->typeName();
+    }
+
   }
 
   http.submitRequest(request, "/IHostService");

+ 3 - 1
Plugins/org.commontk.dicom.wg23.core/ctkDicomServicePrivate.h

@@ -27,6 +27,7 @@
 #include <QEventLoop>
 #include <QtSoapHttpTransport>
 #include <org_commontk_dicom_wg23_core_Export.h>
+#include <ctkDicomExchangeInterface.h>
 
 class org_commontk_dicom_wg23_core_EXPORT ctkDicomServicePrivate : public QObject
 {
@@ -35,7 +36,8 @@ class org_commontk_dicom_wg23_core_EXPORT ctkDicomServicePrivate : public QObjec
 public:
   ctkDicomServicePrivate(int port);
 
-  const QtSoapType & askHost(const QString& methodName, QtSoapType* soapStruct);
+  const QtSoapType & askHost(const QString& methodName, const QList<QtSoapType*>& soapTypes);
+  const QtSoapType & askHost(const QString& methodName, QtSoapType* soapType);
     
   QEventLoop blockingLoop;
   QtSoapHttpTransport http;

+ 26 - 0
Plugins/org.commontk.dicom.wg23.core/ctkDicomWG23TypesHelper.h

@@ -173,5 +173,31 @@ class ctkDicomSoapArrayOfString : public QtSoapArray{
     };
 
 };
+class ctkDicomSoapAvailableData :public QtSoapStruct {
+public:
+    ctkDicomSoapAvailableData ( const QString & name,
+            const ctkDicomWG23::AvailableData& ad ):
+       QtSoapStruct ( QtSoapQName(name) ){
+
+        QList<ctkDicomWG23::ObjectDescriptor> objectDescriptors;
+        QList<ctkDicomWG23::Patient> patients;
+        //TO BE IMPLEMENTED!!!!!!!!!!!!!!!
+        //this->insert(new QtSoapSimpleType(QtSoapQName("StatusType"),
+        //            s.statusType) );
+    };
+   static ctkDicomWG23::AvailableData getAvailableData (const QtSoapType& type){
+        ctkDicomWG23::AvailableData ad;
+        type;
+
+//        s.codingSchemeDesignator =
+//            type["CodingSchemeDesignator"].value().toString();
+//        s.codeValue =
+//            type["CodeValue"].value().toString();
+//        s.codeMeaning =
+//            type["CodeMeaning"].value().toString();
+        return ad;
+   };
+};
+
 
 #endif

+ 5 - 5
Plugins/org.commontk.dicom.wg23.host/ctkDicomAppService.cpp

@@ -25,8 +25,8 @@
 
 #include "ctkDicomWG23TypesHelper.h"
 
-ctkDicomAppService::ctkDicomAppService(int port)
-  : d_ptr(new ctkDicomServicePrivate(port))
+ctkDicomAppService::ctkDicomAppService(ushort port):
+  ctkDicomExchangeService(port)
 {
 
 }
@@ -37,14 +37,14 @@ ctkDicomAppService::~ctkDicomAppService()
 
 ctkDicomWG23::State ctkDicomAppService::getState()
 {
-  Q_D(ctkDicomService);
+  //Q_D(ctkDicomService);
   const QtSoapType & result = d->askHost("getState", NULL);
   return ctkDicomSoapState::getState(result);
 }
 
 bool ctkDicomAppService::setState(ctkDicomWG23::State newState)
 {
-  Q_D(ctkDicomService);
+  //Q_D(ctkDicomService);
   QtSoapType* input = new ctkDicomSoapState("state", newState);
   const QtSoapType & result = d->askHost("setState", input);
   return ctkDicomSoapBool::getBool(result);
@@ -52,7 +52,7 @@ bool ctkDicomAppService::setState(ctkDicomWG23::State newState)
 
 bool ctkDicomAppService::bringToFront(const QRect& requestedScreenArea)
 {
-  Q_D(ctkDicomService);
+  //Q_D(ctkDicomService);
   QtSoapType* input = new ctkDicomSoapRectangle("requestedScreenArea", requestedScreenArea);
   const QtSoapType & result = d->askHost("bringToFront", input);
   return ctkDicomSoapBool::getBool(result);

+ 8 - 10
Plugins/org.commontk.dicom.wg23.host/ctkDicomAppService.h

@@ -20,20 +20,20 @@
 =============================================================================*/
 
 
-#ifndef CTKDICOMHOSTSERVICE_H
-#define CTKDICOMHOSTSERVICE_H
+#ifndef CTKDICOMAPPSERVICE_H
+#define CTKDICOMAPPSERVICE_H
 
 #include <ctkDicomAppInterface.h>
-#include <QScopedPointer>
+#include <ctkDicomExchangeService.h>
 #include <org_commontk_dicom_wg23_host_Export.h>
 
-class ctkDicomServicePrivate;
 
-class org_commontk_dicom_wg23_host_EXPORT ctkDicomAppService : public ctkDicomAppInterface
+class org_commontk_dicom_wg23_host_EXPORT ctkDicomAppService : public ctkDicomExchangeService,
+                                                               public ctkDicomAppInterface
 {
 
 public:
-  ctkDicomAppService(int port);
+  ctkDicomAppService(ushort port);
   ~ctkDicomAppService();
 
   ctkDicomWG23::State getState();
@@ -41,9 +41,7 @@ public:
   bool bringToFront(const QRect& requestedScreenArea);
 
 private:
-  Q_DECLARE_PRIVATE(ctkDicomService)
-
-  const QScopedPointer<ctkDicomServicePrivate> d_ptr;
+  ctkDicomServicePrivate * d;
 };
 
-#endif // CTKDICOMHOSTSERVICE_H
+#endif // CTKDICOMAPPSERVICE_H