changeset 288:8c8da145fefa am-2

renamings and doc
author am@osimis.io
date Thu, 30 Aug 2018 16:52:40 +0200
parents 2038d76bf13f
children 36ebe6ec8fe8
files Applications/BasicApplication.cpp Applications/BasicApplication.h Applications/BasicApplicationContext.cpp Applications/BasicApplicationContext.h Applications/Generic/BasicNativeApplicationContext.h Applications/Generic/BasicNativeApplicationRunner.h Applications/IBasicApplication.h Applications/IStoneApplication.h Applications/Qt/BasicQtApplicationRunner.h Applications/Samples/SampleApplicationBase.h Applications/Samples/SampleMainWasm.cpp Applications/Samples/SimpleViewerApplication.h Applications/StoneApplicationContext.cpp Applications/StoneApplicationContext.h Framework/Toolbox/IWebService.h Platforms/Generic/OracleWebService.h Platforms/Wasm/Defaults.cpp Platforms/Wasm/Defaults.h Resources/CMake/OrthancStoneConfiguration.cmake
diffstat 19 files changed, 164 insertions(+), 509 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/BasicApplication.cpp	Thu Aug 30 11:36:36 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,291 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., 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 "IBasicApplication.h"
-
-#include "../Framework/Toolbox/MessagingToolbox.h"
-#include "Sdl/SdlEngine.h"
-
-#include <Core/Logging.h>
-#include <Core/HttpClient.h>
-#include <Plugins/Samples/Common/OrthancHttpConnection.h>
-
-namespace OrthancStone
-{
-  // Anonymous namespace to avoid clashes against other compilation modules
-  namespace
-  {
-    class LogStatusBar : public IStatusBar
-    {
-    public:
-      virtual void ClearMessage()
-      {
-      }
-
-      virtual void SetMessage(const std::string& message)
-      {
-        LOG(WARNING) << message;
-      }
-    };
-  }
-
-
-#if ORTHANC_ENABLE_SDL == 1
-  static void DeclareSdlCommandLineOptions(boost::program_options::options_description& options)
-  {
-    // Declare the supported parameters
-    boost::program_options::options_description generic("Generic options");
-    generic.add_options()
-      ("help", "Display this help and exit")
-      ("verbose", "Be verbose in logs")
-      ("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"),
-       "URL to the Orthanc server")
-      ("username", "Username for the Orthanc server")
-      ("password", "Password for the Orthanc server")
-      ("https-verify", boost::program_options::value<bool>()->default_value(true), "Check HTTPS certificates")
-      ;
-
-    options.add(generic);
-
-    boost::program_options::options_description sdl("SDL options");
-    sdl.add_options()
-      ("width", boost::program_options::value<int>()->default_value(1024), "Initial width of the SDL window")
-      ("height", boost::program_options::value<int>()->default_value(768), "Initial height of the SDL window")
-      ("opengl", boost::program_options::value<bool>()->default_value(true), "Enable OpenGL in SDL")
-      ;
-
-    options.add(sdl);
-  }
-
-
-  int IBasicApplication::ExecuteWithSdl(IBasicApplication& application,
-                                        int argc, 
-                                        char* argv[])
-  {
-    /******************************************************************
-     * Initialize all the subcomponents of Orthanc Stone
-     ******************************************************************/
-
-    Orthanc::Logging::Initialize();
-    Orthanc::HttpClient::InitializeOpenSsl();
-    Orthanc::HttpClient::GlobalInitialize();
-    SdlWindow::GlobalInitialize();
-
-
-    /******************************************************************
-     * Declare and parse the command-line options of the application
-     ******************************************************************/
-
-    boost::program_options::options_description options;
-    DeclareSdlCommandLineOptions(options);   
-    application.DeclareCommandLineOptions(options);
-
-    boost::program_options::variables_map parameters;
-    bool error = false;
-
-    try
-    {
-      boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
-                                    options(options).run(), parameters);
-      boost::program_options::notify(parameters);    
-    }
-    catch (boost::program_options::error& e)
-    {
-      LOG(ERROR) << "Error while parsing the command-line arguments: " << e.what();
-      error = true;
-    }
-
-
-    /******************************************************************
-     * Configure the application with the command-line parameters
-     ******************************************************************/
-
-    if (error || parameters.count("help")) 
-    {
-      std::cout << std::endl
-                << "Usage: " << argv[0] << " [OPTION]..."
-                << std::endl
-                << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research."
-                << std::endl << std::endl
-                << "Demonstration application of Orthanc Stone using SDL."
-                << std::endl;
-
-      std::cout << options << "\n";
-      return error ? -1 : 0;
-    }
-
-    if (parameters.count("https-verify") &&
-        !parameters["https-verify"].as<bool>())
-    {
-      LOG(WARNING) << "Turning off verification of HTTPS certificates (unsafe)";
-      Orthanc::HttpClient::ConfigureSsl(false, "");
-    }
-
-    if (parameters.count("verbose"))
-    {
-      Orthanc::Logging::EnableInfoLevel(true);
-    }
-
-    if (!parameters.count("width") ||
-        !parameters.count("height") ||
-        !parameters.count("opengl"))
-    {
-      LOG(ERROR) << "Parameter \"width\", \"height\" or \"opengl\" is missing";
-      return -1;
-    }
-
-    int w = parameters["width"].as<int>();
-    int h = parameters["height"].as<int>();
-    if (w <= 0 || h <= 0)
-    {
-      LOG(ERROR) << "Parameters \"width\" and \"height\" must be positive";
-      return -1;
-    }
-
-    unsigned int width = static_cast<unsigned int>(w);
-    unsigned int height = static_cast<unsigned int>(h);
-    LOG(WARNING) << "Initial display size: " << width << "x" << height;
-
-    bool opengl = parameters["opengl"].as<bool>();
-    if (opengl)
-    {
-      LOG(WARNING) << "OpenGL is enabled, disable it with option \"--opengl=off\" if the application crashes";
-    }
-    else
-    {
-      LOG(WARNING) << "OpenGL is disabled, enable it with option \"--opengl=on\" for best performance";
-    }
-
-    bool success = true;
-    try
-    {
-      /****************************************************************
-       * Initialize the connection to the Orthanc server
-       ****************************************************************/
-
-      Orthanc::WebServiceParameters webService;
-
-      if (parameters.count("orthanc"))
-      {
-        webService.SetUrl(parameters["orthanc"].as<std::string>());
-      }
-
-      if (parameters.count("username"))
-      {
-        webService.SetUsername(parameters["username"].as<std::string>());
-      }
-
-      if (parameters.count("password"))
-      {
-        webService.SetPassword(parameters["password"].as<std::string>());
-      }
-
-      LOG(WARNING) << "URL to the Orthanc REST API: " << webService.GetUrl();
-
-      {
-        OrthancPlugins::OrthancHttpConnection orthanc(webService);
-        if (!MessagingToolbox::CheckOrthancVersion(orthanc))
-        {
-          LOG(ERROR) << "Your version of Orthanc is incompatible with Stone of Orthanc, please upgrade";
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
-        }
-      }
-
-
-      /****************************************************************
-       * Initialize the application
-       ****************************************************************/
-
-      LOG(WARNING) << "Creating the widgets of the application";
-
-      LogStatusBar statusBar;
-      BasicApplicationContext context(webService);
-
-      application.Initialize(context, statusBar, parameters);
-
-      {
-        BasicApplicationContext::ViewportLocker locker(context);
-        locker.GetViewport().SetStatusBar(statusBar);
-      }
-
-      std::string title = application.GetTitle();
-      if (title.empty())
-      {
-        title = "Stone of Orthanc";
-      }
-
-      {
-        /**************************************************************
-         * Run the application inside a SDL window
-         **************************************************************/
-
-        LOG(WARNING) << "Starting the application";
-
-        SdlWindow window(title.c_str(), width, height, opengl);
-        SdlEngine sdl(window, context);
-
-        {
-          BasicApplicationContext::ViewportLocker locker(context);
-          locker.GetViewport().Register(sdl);  // (*)
-        }
-
-        context.Start();
-        sdl.Run();
-
-        LOG(WARNING) << "Stopping the application";
-
-        // Don't move the "Stop()" command below out of the block,
-        // otherwise the application might crash, because the
-        // "SdlEngine" is an observer of the viewport (*) and the
-        // update thread started by "context.Start()" would call a
-        // destructed object (the "SdlEngine" is deleted with the
-        // lexical scope).
-        context.Stop();
-      }
-
-
-      /****************************************************************
-       * Finalize the application
-       ****************************************************************/
-
-      LOG(WARNING) << "The application has stopped";
-      application.Finalize();
-    }
-    catch (Orthanc::OrthancException& e)
-    {
-      LOG(ERROR) << "EXCEPTION: " << e.What();
-      success = false;
-    }
-
-
-    /******************************************************************
-     * Finalize all the subcomponents of Orthanc Stone
-     ******************************************************************/
-
-    SdlWindow::GlobalFinalize();
-    Orthanc::HttpClient::GlobalFinalize();
-    Orthanc::HttpClient::FinalizeOpenSsl();
-
-    return (success ? 0 : -1);
-  }
-#endif
-
-}
--- a/Applications/BasicApplication.h	Thu Aug 30 11:36:36 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., 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 "BasicApplicationContext.h"
-
-#include <boost/program_options.hpp>
-
-#if ORTHANC_ENABLE_SDL == 1
-#  include <SDL.h>   // Necessary to avoid undefined reference to `SDL_main'
-#endif
-
-namespace OrthancStone
-{
-  class IBasicApplication : public boost::noncopyable
-  {
-  public:
-    virtual ~IBasicApplication()
-    {
-    }
-
-    virtual void DeclareStartupOption(const std::string& name, const std::string& defaultValue, const std::string& helpText) = 0;
-    virtual void Initialize(IStatusBar& statusBar, const std::map<std::string, std::string> startupOptions);
-
-
-    virtual void DeclareCommandLineOptions(boost::program_options::options_description& options) = 0;
-
-    virtual std::string GetTitle() const = 0;
-
-    virtual void Initialize(BasicApplicationContext& context,
-                            IStatusBar& statusBar,
-                            const boost::program_options::variables_map& parameters) = 0;
-
-    virtual void Finalize() = 0;
-
-#if ORTHANC_ENABLE_SDL == 1
-    static int ExecuteWithSdl(IBasicApplication& application,
-                              int argc, 
-                              char* argv[]);
-#endif
-  };
-
-  class IBasicSdlApplication : public IBasicApplication
-  {
-    public:
-
-    
-  }
-}
--- a/Applications/BasicApplicationContext.cpp	Thu Aug 30 11:36:36 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., 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 "BasicApplicationContext.h"
-
-namespace OrthancStone
-{
-}
--- a/Applications/BasicApplicationContext.h	Thu Aug 30 11:36:36 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., 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 "../Framework/Toolbox/IWebService.h"
-#include "../Framework/Viewport/WidgetViewport.h"
-
-#include <list>
-
-namespace OrthancStone
-{
-  class BasicApplicationContext : public boost::noncopyable
-  {
-
-  protected:
-    IWebService* webService_;
-  public:
-    BasicApplicationContext()
-      : webService_(NULL)
-    {
-    }
-
-    IWebService& GetWebService() {return *webService_;}
-    void SetWebService(IWebService& webService)
-    {
-      webService_ = &webService;
-    }
-//    virtual IWidget& SetCentralWidget(IWidget* widget) = 0;   // Takes ownership
-
-    virtual ~BasicApplicationContext() {}
-  };
-}
--- a/Applications/Generic/BasicNativeApplicationContext.h	Thu Aug 30 11:36:36 2018 +0200
+++ b/Applications/Generic/BasicNativeApplicationContext.h	Thu Aug 30 16:52:40 2018 +0200
@@ -27,11 +27,11 @@
 
 #include <list>
 #include <boost/thread.hpp>
-#include "../BasicApplicationContext.h"
+#include "../StoneApplicationContext.h"
 
 namespace OrthancStone
 {
-  class BasicNativeApplicationContext : public BasicApplicationContext
+  class BasicNativeApplicationContext : public StoneApplicationContext
   {
   private:
 
--- a/Applications/Generic/BasicNativeApplicationRunner.h	Thu Aug 30 11:36:36 2018 +0200
+++ b/Applications/Generic/BasicNativeApplicationRunner.h	Thu Aug 30 16:52:40 2018 +0200
@@ -21,7 +21,7 @@
 
 #pragma once
 
-#include "../IBasicApplication.h"
+#include "../IStoneApplication.h"
 
 #if ORTHANC_ENABLE_NATIVE != 1
 #error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
@@ -35,11 +35,11 @@
   {
   protected:
     MessageBroker&      broker_;
-    IBasicApplication&  application_;
+    IStoneApplication&  application_;
   public:
 
     BasicNativeApplicationRunner(MessageBroker& broker,
-                                 IBasicApplication& application)
+                                 IStoneApplication& application)
       : broker_(broker),
         application_(application)
     {
--- a/Applications/IBasicApplication.h	Thu Aug 30 11:36:36 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., 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 "BasicApplicationContext.h"
-#include <boost/program_options.hpp>
-#include "../Framework/Viewport/WidgetViewport.h"
-#include "json/json.h"
-
-namespace OrthancStone
-{
-  class IBasicApplication : public boost::noncopyable
-  {
-  protected:
-    BasicApplicationContext* context_;
-
-  public:
-    virtual ~IBasicApplication()
-    {
-    }
-
-    virtual void DeclareStartupOptions(boost::program_options::options_description& options) = 0;
-    virtual void Initialize(BasicApplicationContext* context,
-                            IStatusBar& statusBar,
-                            const boost::program_options::variables_map& parameters) = 0;
-#if ORTHANC_ENABLE_WASM==1
-    virtual void InitializeWasm() {}  // specific initialization when the app is running in WebAssembly.  This is called after the other Initialize()
-#endif
-
-    virtual std::string GetTitle() const = 0;
-    virtual IWidget* GetCentralWidget() = 0;
-
-    virtual void Finalize() = 0;
-  };
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/IStoneApplication.h	Thu Aug 30 16:52:40 2018 +0200
@@ -0,0 +1,58 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., 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 "StoneApplicationContext.h"
+#include <boost/program_options.hpp>
+#include "../Framework/Viewport/WidgetViewport.h"
+#include "json/json.h"
+
+namespace OrthancStone
+{
+  // a StoneApplication is an application that can actually be executed
+  // in multiple environments.  i.e: it can run natively integrated in a QtApplication
+  // or it can be executed as part of a WebPage when compiled into WebAssembly.
+  class IStoneApplication : public boost::noncopyable
+  {
+  protected:
+    StoneApplicationContext* context_;
+
+  public:
+    virtual ~IStoneApplication()
+    {
+    }
+
+    virtual void DeclareStartupOptions(boost::program_options::options_description& options) = 0;
+    virtual void Initialize(StoneApplicationContext* context,
+                            IStatusBar& statusBar,
+                            const boost::program_options::variables_map& parameters) = 0;
+#if ORTHANC_ENABLE_WASM==1
+    virtual void InitializeWasm() {}  // specific initialization when the app is running in WebAssembly.  This is called after the other Initialize()
+#endif
+
+    virtual std::string GetTitle() const = 0;
+    virtual IWidget* GetCentralWidget() = 0;
+
+    virtual void Finalize() = 0;
+  };
+
+}
--- a/Applications/Qt/BasicQtApplicationRunner.h	Thu Aug 30 11:36:36 2018 +0200
+++ b/Applications/Qt/BasicQtApplicationRunner.h	Thu Aug 30 16:52:40 2018 +0200
@@ -38,7 +38,7 @@
     virtual void InitializeMainWindow(BasicNativeApplicationContext& context) = 0;
   public:
     BasicQtApplicationRunner(MessageBroker& broker,
-                             IBasicApplication& application)
+                             IStoneApplication& application)
       : BasicNativeApplicationRunner(broker, application)
     {
     }
--- a/Applications/Samples/SampleApplicationBase.h	Thu Aug 30 11:36:36 2018 +0200
+++ b/Applications/Samples/SampleApplicationBase.h	Thu Aug 30 16:52:40 2018 +0200
@@ -21,16 +21,16 @@
 
 #pragma once
 
-#include "../../Applications/IBasicApplication.h"
+#include "../../Applications/IStoneApplication.h"
 
 namespace OrthancStone
 {
   namespace Samples
   {
-    class SampleApplicationBase : public IBasicApplication
+    class SampleApplicationBase : public IStoneApplication
     {
     public:
-      virtual void Initialize(BasicApplicationContext* context,
+      virtual void Initialize(StoneApplicationContext* context,
                               IStatusBar& statusBar,
                               const boost::program_options::variables_map& parameters)
       {
--- a/Applications/Samples/SampleMainWasm.cpp	Thu Aug 30 11:36:36 2018 +0200
+++ b/Applications/Samples/SampleMainWasm.cpp	Thu Aug 30 16:52:40 2018 +0200
@@ -26,7 +26,7 @@
 #include "SampleList.h"
 
 
-OrthancStone::IBasicApplication* CreateUserApplication(OrthancStone::MessageBroker& broker) {
+OrthancStone::IStoneApplication* CreateUserApplication(OrthancStone::MessageBroker& broker) {
   
   return new SampleApplication(broker);
 }
\ No newline at end of file
--- a/Applications/Samples/SimpleViewerApplication.h	Thu Aug 30 11:36:36 2018 +0200
+++ b/Applications/Samples/SimpleViewerApplication.h	Thu Aug 30 16:52:40 2018 +0200
@@ -226,7 +226,7 @@
         options.add(generic);
       }
 
-      virtual void Initialize(BasicApplicationContext* context,
+      virtual void Initialize(StoneApplicationContext* context,
                               IStatusBar& statusBar,
                               const boost::program_options::variables_map& parameters)
       {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/StoneApplicationContext.cpp	Thu Aug 30 16:52:40 2018 +0200
@@ -0,0 +1,26 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., 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 "StoneApplicationContext.h"
+
+namespace OrthancStone
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/StoneApplicationContext.h	Thu Aug 30 16:52:40 2018 +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-2018 Osimis S.A., 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 "../Framework/Toolbox/IWebService.h"
+#include "../Framework/Viewport/WidgetViewport.h"
+
+#include <list>
+
+namespace OrthancStone
+{
+  // a StoneApplicationContext contains the services that a StoneApplication
+  // uses and that depends on the environment in which the Application executes.
+  // I.e, the StoneApplicationContext provides a WebService interface such that
+  // the StoneApplication can perform HTTP requests.  In a WASM environment,
+  // the WebService is provided by the browser while, in a native environment,
+  // the WebService is provided by the OracleWebService (a C++ Http client)
+  class StoneApplicationContext : public boost::noncopyable
+  {
+
+  protected:
+    IWebService* webService_;
+  public:
+    StoneApplicationContext()
+      : webService_(NULL)
+    {
+    }
+
+    IWebService& GetWebService() {return *webService_;}
+    void SetWebService(IWebService& webService)
+    {
+      webService_ = &webService;
+    }
+
+    virtual ~StoneApplicationContext() {}
+  };
+}
--- a/Framework/Toolbox/IWebService.h	Thu Aug 30 11:36:36 2018 +0200
+++ b/Framework/Toolbox/IWebService.h	Thu Aug 30 16:52:40 2018 +0200
@@ -28,6 +28,11 @@
 
 namespace OrthancStone
 {
+  // The IWebService performs HTTP requests.
+  // Since applications can run in native or WASM environment and, since
+  // in a WASM environment, the WebService is asynchronous, the IWebservice
+  // also implements an asynchronous interface: you must schedule a request
+  // and you'll be notified when the response/error is ready.
   class IWebService
   {
   protected:
--- a/Platforms/Generic/OracleWebService.h	Thu Aug 30 11:36:36 2018 +0200
+++ b/Platforms/Generic/OracleWebService.h	Thu Aug 30 16:52:40 2018 +0200
@@ -29,6 +29,7 @@
 
 namespace OrthancStone
 {
+  // The OracleWebService performs HTTP requests in a native environment.
   class OracleWebService : public IWebService
   {
   private:
--- a/Platforms/Wasm/Defaults.cpp	Thu Aug 30 11:36:36 2018 +0200
+++ b/Platforms/Wasm/Defaults.cpp	Thu Aug 30 16:52:40 2018 +0200
@@ -14,9 +14,9 @@
 
 /**********************************/
 
-static std::unique_ptr<OrthancStone::IBasicApplication> application;
+static std::unique_ptr<OrthancStone::IStoneApplication> application;
 static OrthancStone::IStoneApplicationToWebApplicationAdapter* applicationWebAdapter = NULL;
-static std::unique_ptr<OrthancStone::BasicApplicationContext> context;
+static std::unique_ptr<OrthancStone::StoneApplicationContext> context;
 static OrthancStone::StartupParametersBuilder startupParametersBuilder;
 static OrthancStone::MessageBroker broker;
 
@@ -90,7 +90,7 @@
     application->DeclareStartupOptions(options);
     startupParametersBuilder.GetStartupParameters(parameters, options);
 
-    context.reset(new OrthancStone::BasicApplicationContext());
+    context.reset(new OrthancStone::StoneApplicationContext());
     context->SetWebService(OrthancStone::WasmWebService::GetInstance());
     application->Initialize(context.get(), statusBar_, parameters);
     application->InitializeWasm();
--- a/Platforms/Wasm/Defaults.h	Thu Aug 30 11:36:36 2018 +0200
+++ b/Platforms/Wasm/Defaults.h	Thu Aug 30 16:52:40 2018 +0200
@@ -6,7 +6,7 @@
 #include <Framework/Viewport/WidgetViewport.h>
 #include <Framework/Widgets/LayerWidget.h>
 #include <Framework/Widgets/LayoutWidget.h>
-#include <Applications/IBasicApplication.h>
+#include <Applications/IStoneApplication.h>
 
 typedef OrthancStone::WidgetViewport* ViewportHandle; // the objects exchanged between JS and C++
 
@@ -27,7 +27,7 @@
 }
 #endif
 
-extern OrthancStone::IBasicApplication* CreateUserApplication(OrthancStone::MessageBroker& broker);
+extern OrthancStone::IStoneApplication* CreateUserApplication(OrthancStone::MessageBroker& broker);
 
 namespace OrthancStone {
 
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Thu Aug 30 11:36:36 2018 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Thu Aug 30 16:52:40 2018 +0200
@@ -162,8 +162,8 @@
 #####################################################################
 
 set(APPLICATIONS_SOURCES
-    ${ORTHANC_STONE_ROOT}/Applications/IBasicApplication.h
-    ${ORTHANC_STONE_ROOT}/Applications/BasicApplicationContext.cpp
+    ${ORTHANC_STONE_ROOT}/Applications/IStoneApplication.h
+    ${ORTHANC_STONE_ROOT}/Applications/StoneApplicationContext.cpp
     )
 
 if (NOT ORTHANC_SANDBOXED)