changeset 69:1553b67b24e5 wasm

OrthancSynchronousWebService
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 May 2017 20:35:11 +0200
parents 1526d38ef6da
children f73aed014bde
files Applications/BasicApplicationContext.cpp Applications/BasicApplicationContext.h Applications/IBasicApplication.cpp Framework/Toolbox/OrthancSynchronousWebService.cpp Framework/Toolbox/OrthancSynchronousWebService.h Framework/Toolbox/OrthancWebService.cpp Framework/Toolbox/OrthancWebService.h Resources/CMake/OrthancStone.cmake UnitTestsSources/UnitTestsMain.cpp
diffstat 9 files changed, 144 insertions(+), 144 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/BasicApplicationContext.cpp	Mon May 22 17:49:26 2017 +0200
+++ b/Applications/BasicApplicationContext.cpp	Mon May 22 20:35:11 2017 +0200
@@ -41,7 +41,7 @@
   }
   
 
-  BasicApplicationContext::BasicApplicationContext(OrthancWebService& orthanc) :
+  BasicApplicationContext::BasicApplicationContext(OrthancSynchronousWebService& orthanc) :
     orthanc_(orthanc),
     stopped_(true),
     updateDelay_(100)   // By default, 100ms between each refresh of the content
--- a/Applications/BasicApplicationContext.h	Mon May 22 17:49:26 2017 +0200
+++ b/Applications/BasicApplicationContext.h	Mon May 22 20:35:11 2017 +0200
@@ -25,7 +25,7 @@
 #include "../../Framework/Viewport/WidgetViewport.h"
 #include "../../Framework/Widgets/IWorldSceneInteractor.h"
 #include "../../Framework/Toolbox/DicomStructureSet.h"
-#include "../../Framework/Toolbox/OrthancWebService.h"
+#include "../../Framework/Toolbox/OrthancSynchronousWebService.h"
 
 #include <list>
 #include <boost/thread.hpp>
@@ -41,7 +41,7 @@
 
     static void UpdateThread(BasicApplicationContext* that);
 
-    OrthancWebService&  orthanc_;
+    OrthancSynchronousWebService&  orthanc_;
     boost::mutex        viewportMutex_;
     WidgetViewport      viewport_;
     Volumes             volumes_;
@@ -72,13 +72,13 @@
     };
 
     
-    BasicApplicationContext(OrthancWebService& orthanc);
+    BasicApplicationContext(OrthancSynchronousWebService& orthanc);
 
     ~BasicApplicationContext();
 
     IWidget& SetCentralWidget(IWidget* widget);   // Takes ownership
 
-    OrthancWebService& GetWebService()
+    OrthancSynchronousWebService& GetWebService()
     {
       return orthanc_;
     }
--- a/Applications/IBasicApplication.cpp	Mon May 22 17:49:26 2017 +0200
+++ b/Applications/IBasicApplication.cpp	Mon May 22 20:35:11 2017 +0200
@@ -197,7 +197,7 @@
       }
 
       LOG(WARNING) << "URL to the Orthanc REST API: " << webService.GetUrl();
-      OrthancWebService orthanc(webService);
+      OrthancSynchronousWebService orthanc(webService);
 
       if (!MessagingToolbox::CheckOrthancVersion(orthanc.GetConnection()))
       {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Framework/Toolbox/OrthancSynchronousWebService.cpp	Mon May 22 20:35:11 2017 +0200
@@ -0,0 +1,79 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017 Osimis, 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/>.
+ **/
+
+
+#include "OrthancSynchronousWebService.h"
+
+#include "../../Resources/Orthanc/Core/OrthancException.h"
+#include "../../Resources/Orthanc/Plugins/Samples/Common/OrthancHttpConnection.h"
+
+namespace OrthancStone
+{
+  OrthancSynchronousWebService::OrthancSynchronousWebService(OrthancPlugins::IOrthancConnection* orthanc) :
+    orthanc_(orthanc)
+  {
+    if (orthanc == NULL)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
+    }
+  }
+  
+  OrthancSynchronousWebService::OrthancSynchronousWebService(const Orthanc::WebServiceParameters& parameters)
+  {
+    orthanc_.reset(new OrthancPlugins::OrthancHttpConnection(parameters));
+  }    
+
+  void OrthancSynchronousWebService::ScheduleGetRequest(ICallback& callback,
+                                             const std::string& uri,
+                                             Orthanc::IDynamicObject* payload)
+  {
+    std::auto_ptr<Orthanc::IDynamicObject> tmp(payload);
+
+    try
+    {
+      std::string answer;
+      orthanc_->RestApiGet(answer, uri);
+      callback.NotifySuccess(uri, answer.c_str(), answer.size(), tmp.release());
+    }
+    catch (Orthanc::OrthancException&)
+    {
+      callback.NotifyError(uri, tmp.release());
+    }
+  }
+
+  void OrthancSynchronousWebService::SchedulePostRequest(ICallback& callback,
+                                              const std::string& uri,
+                                              const std::string& body,
+                                              Orthanc::IDynamicObject* payload)
+  {
+    std::auto_ptr<Orthanc::IDynamicObject> tmp(payload);
+
+    try
+    {
+      std::string answer;
+      orthanc_->RestApiPost(answer, uri, body);
+      callback.NotifySuccess(uri, answer.c_str(), answer.size(), tmp.release());
+    }
+    catch (Orthanc::OrthancException&)
+    {
+      callback.NotifyError(uri, tmp.release());
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Framework/Toolbox/OrthancSynchronousWebService.h	Mon May 22 20:35:11 2017 +0200
@@ -0,0 +1,56 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017 Osimis, 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 "IWebService.h"
+#include "../../Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.h"
+#include "../../Resources/Orthanc/Core/WebServiceParameters.h"
+
+#include <memory>
+
+namespace OrthancStone
+{
+  class OrthancSynchronousWebService : public IWebService
+  {
+  private:
+    std::auto_ptr<OrthancPlugins::IOrthancConnection>  orthanc_;
+    
+  public:
+    OrthancSynchronousWebService(OrthancPlugins::IOrthancConnection* orthanc);  // Takes ownership
+    
+    OrthancSynchronousWebService(const Orthanc::WebServiceParameters& parameters);
+
+    OrthancPlugins::IOrthancConnection& GetConnection()
+    {
+      return *orthanc_;
+    }
+    
+    virtual void ScheduleGetRequest(ICallback& callback,
+                                    const std::string& uri,
+                                    Orthanc::IDynamicObject* payload);
+
+    virtual void SchedulePostRequest(ICallback& callback,
+                                     const std::string& uri,
+                                     const std::string& body,
+                                     Orthanc::IDynamicObject* payload);
+  };
+}
--- a/Framework/Toolbox/OrthancWebService.cpp	Mon May 22 17:49:26 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017 Osimis, 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/>.
- **/
-
-
-#include "OrthancWebService.h"
-
-#include "../../Resources/Orthanc/Core/OrthancException.h"
-#include "../../Resources/Orthanc/Plugins/Samples/Common/OrthancHttpConnection.h"
-
-namespace OrthancStone
-{
-  OrthancWebService::OrthancWebService(OrthancPlugins::IOrthancConnection* orthanc) :
-    orthanc_(orthanc)
-  {
-    if (orthanc == NULL)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
-    }
-  }
-  
-  OrthancWebService::OrthancWebService(const Orthanc::WebServiceParameters& parameters)
-  {
-    orthanc_.reset(new OrthancPlugins::OrthancHttpConnection(parameters));
-  }    
-
-  void OrthancWebService::ScheduleGetRequest(ICallback& callback,
-                                             const std::string& uri,
-                                             Orthanc::IDynamicObject* payload)
-  {
-    std::auto_ptr<Orthanc::IDynamicObject> tmp(payload);
-
-    try
-    {
-      std::string answer;
-      orthanc_->RestApiGet(answer, uri);
-      callback.NotifySuccess(uri, answer.c_str(), answer.size(), tmp.release());
-    }
-    catch (Orthanc::OrthancException&)
-    {
-      callback.NotifyError(uri, tmp.release());
-    }
-  }
-
-  void OrthancWebService::SchedulePostRequest(ICallback& callback,
-                                              const std::string& uri,
-                                              const std::string& body,
-                                              Orthanc::IDynamicObject* payload)
-  {
-    std::auto_ptr<Orthanc::IDynamicObject> tmp(payload);
-
-    try
-    {
-      std::string answer;
-      orthanc_->RestApiPost(answer, uri, body);
-      callback.NotifySuccess(uri, answer.c_str(), answer.size(), tmp.release());
-    }
-    catch (Orthanc::OrthancException&)
-    {
-      callback.NotifyError(uri, tmp.release());
-    }
-  }
-}
--- a/Framework/Toolbox/OrthancWebService.h	Mon May 22 17:49:26 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017 Osimis, 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 "IWebService.h"
-#include "../../Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.h"
-#include "../../Resources/Orthanc/Core/WebServiceParameters.h"
-
-#include <memory>
-
-namespace OrthancStone
-{
-  class OrthancWebService : public IWebService
-  {
-  private:
-    std::auto_ptr<OrthancPlugins::IOrthancConnection>  orthanc_;
-    
-  public:
-    OrthancWebService(OrthancPlugins::IOrthancConnection* orthanc);  // Takes ownership
-    
-    OrthancWebService(const Orthanc::WebServiceParameters& parameters);
-
-    OrthancPlugins::IOrthancConnection& GetConnection()
-    {
-      return *orthanc_;
-    }
-    
-    virtual void ScheduleGetRequest(ICallback& callback,
-                                    const std::string& uri,
-                                    Orthanc::IDynamicObject* payload);
-
-    virtual void SchedulePostRequest(ICallback& callback,
-                                     const std::string& uri,
-                                     const std::string& body,
-                                     Orthanc::IDynamicObject* payload);
-  };
-}
--- a/Resources/CMake/OrthancStone.cmake	Mon May 22 17:49:26 2017 +0200
+++ b/Resources/CMake/OrthancStone.cmake	Mon May 22 20:35:11 2017 +0200
@@ -201,7 +201,7 @@
   ${ORTHANC_STONE_DIR}/Framework/Toolbox/GeometryToolbox.cpp
   ${ORTHANC_STONE_DIR}/Framework/Toolbox/MessagingToolbox.cpp
   ${ORTHANC_STONE_DIR}/Framework/Toolbox/OrthancSeriesLoader.cpp
-  ${ORTHANC_STONE_DIR}/Framework/Toolbox/OrthancWebService.cpp
+  ${ORTHANC_STONE_DIR}/Framework/Toolbox/OrthancSynchronousWebService.cpp
   ${ORTHANC_STONE_DIR}/Framework/Toolbox/ParallelSlices.cpp
   ${ORTHANC_STONE_DIR}/Framework/Toolbox/ParallelSlicesCursor.cpp
   ${ORTHANC_STONE_DIR}/Framework/Toolbox/SliceGeometry.cpp
--- a/UnitTestsSources/UnitTestsMain.cpp	Mon May 22 17:49:26 2017 +0200
+++ b/UnitTestsSources/UnitTestsMain.cpp	Mon May 22 20:35:11 2017 +0200
@@ -22,7 +22,7 @@
 #include "gtest/gtest.h"
 
 #include "../Resources/Orthanc/Core/Logging.h"
-#include "../Framework/Toolbox/OrthancWebService.h"
+#include "../Framework/Toolbox/OrthancSynchronousWebService.h"
 #include "../Framework/Layers/OrthancFrameLayerSource.h"
 #include "../Framework/Widgets/LayerWidget.h"
 
@@ -733,7 +733,7 @@
 TEST(Toto, Tutu)
 {
   Orthanc::WebServiceParameters web;
-  OrthancStone::OrthancWebService orthanc(web);
+  OrthancStone::OrthancSynchronousWebService orthanc(web);
 
   OrthancStone::Tata tata;
   OrthancStone::OrthancSliceLoader loader(tata, orthanc);