From 07d7d7f01c19106a2757e64af74224fe154cf768 2017-12-11 09:31:17 From: Alexandre Leroux Date: 2017-12-11 09:31:17 Subject: [PATCH] Adds "local server" mode This mode will use AMDA server launched on localhost --- diff --git a/cmake/sciqlop_applications.cmake b/cmake/sciqlop_applications.cmake index c0a9258..3509844 100644 --- a/cmake/sciqlop_applications.cmake +++ b/cmake/sciqlop_applications.cmake @@ -32,6 +32,7 @@ IF(BUILD_PLUGINS) # - "default": default AMDA server # - "amdatest": AMDA test server # - "hybrid": use both the default server and the test server (the server used is relative to each product, according to its "server" property in the JSON file) + # - "localhost": use local AMDA server # Any other value will lead to the use of the default server ADD_DEFINITIONS(-DSCIQLOP_AMDA_SERVER="hybrid") diff --git a/meson.build b/meson.build index 4cc8ed1..5a77de9 100644 --- a/meson.build +++ b/meson.build @@ -27,6 +27,7 @@ endif # - "default": default AMDA server # - "amdatest": AMDA test server # - "hybrid": use both the default server and the test server (the server used is relative to each product, according to its "server" property in the JSON file) +# - "localhost": use local AMDA server # Any other value will lead to the use of the default server add_project_arguments('-DSCIQLOP_AMDA_SERVER="hybrid"', language : 'cpp') diff --git a/plugins/amda/src/AmdaServer.cpp b/plugins/amda/src/AmdaServer.cpp index 8306d0e..66c11cf 100644 --- a/plugins/amda/src/AmdaServer.cpp +++ b/plugins/amda/src/AmdaServer.cpp @@ -12,6 +12,13 @@ const auto AMDA_DEFAULT_SERVER_URL = QStringLiteral("amda.irap.omp.eu"); /// URL of the AMDA test server const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu"); +/// Port used for local server +const auto AMDA_LOCAL_SERVER_PORT = 6543; + +/// URL of the local server +const auto AMDA_LOCAL_SERVER_URL + = QString{"localhost:%1"}.arg(QString::number(AMDA_LOCAL_SERVER_PORT)); + /// Default AMDA server struct AmdaDefaultServer : public AmdaServer { public: @@ -48,6 +55,17 @@ public: } }; +/// Local AMDA server: use local python server to simulate AMDA requests +struct AmdaLocalServer : public AmdaServer { +public: + QString name() const override { return AMDA_LOCAL_SERVER_URL; } + QString url(const QVariantHash &properties) const override + { + Q_UNUSED(properties); + return AMDA_LOCAL_SERVER_URL; + } +}; + /// @return an AMDA server instance created from the name of the server passed in parameter. If the /// name does not match any known server, a default server instance is created std::unique_ptr createInstance(const QString &server) @@ -58,6 +76,9 @@ std::unique_ptr createInstance(const QString &server) else if (server == QString{"hybrid"}) { return std::make_unique(); } + else if (server == QString{"localhost"}) { + return std::make_unique(); + } else { if (server != QString{"default"}) { qCWarning(LOG_AmdaServer())