##// END OF EJS Templates
Adds "local server" mode...
Alexandre Leroux -
r1120:07d7d7f01c19
parent child
Show More
@@ -1,73 +1,74
1
1
2 if(BUILD_TESTS)
2 if(BUILD_TESTS)
3 INCLUDE ("cmake/sciqlop_code_coverage.cmake")
3 INCLUDE ("cmake/sciqlop_code_coverage.cmake")
4 APPEND_COVERAGE_COMPILER_FLAGS()
4 APPEND_COVERAGE_COMPILER_FLAGS()
5 endif(BUILD_TESTS)
5 endif(BUILD_TESTS)
6
6
7 #
7 #
8 # Compile the diffents modules
8 # Compile the diffents modules
9 #
9 #
10 set(sciqlop-plugin_DIR "${CMAKE_SOURCE_DIR}/plugin/cmake")
10 set(sciqlop-plugin_DIR "${CMAKE_SOURCE_DIR}/plugin/cmake")
11 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-plugin_DIR}")
11 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-plugin_DIR}")
12 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugin")
12 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugin")
13
13
14 set(sciqlop-core_DIR "${CMAKE_SOURCE_DIR}/core/cmake")
14 set(sciqlop-core_DIR "${CMAKE_SOURCE_DIR}/core/cmake")
15 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-core_DIR}")
15 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-core_DIR}")
16 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/core")
16 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/core")
17
17
18 set(sciqlop-gui_DIR "${CMAKE_SOURCE_DIR}/gui/cmake")
18 set(sciqlop-gui_DIR "${CMAKE_SOURCE_DIR}/gui/cmake")
19 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-gui_DIR}")
19 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-gui_DIR}")
20 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui")
20 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui")
21
21
22 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app")
22 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app")
23
23
24 OPTION (BUILD_PLUGINS "Build the plugins" OFF)
24 OPTION (BUILD_PLUGINS "Build the plugins" OFF)
25 IF(BUILD_PLUGINS)
25 IF(BUILD_PLUGINS)
26 set(sciqlop-mockplugin_DIR "${CMAKE_SOURCE_DIR}/plugins/mockplugin/cmake")
26 set(sciqlop-mockplugin_DIR "${CMAKE_SOURCE_DIR}/plugins/mockplugin/cmake")
27 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-mockplugin_DIR}")
27 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-mockplugin_DIR}")
28 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/mockplugin")
28 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/mockplugin")
29
29
30 # Sets AMDA server that will be used during execution.
30 # Sets AMDA server that will be used during execution.
31 # Available values are:
31 # Available values are:
32 # - "default": default AMDA server
32 # - "default": default AMDA server
33 # - "amdatest": AMDA test server
33 # - "amdatest": AMDA test server
34 # - "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)
34 # - "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)
35 # - "localhost": use local AMDA server
35 # Any other value will lead to the use of the default server
36 # Any other value will lead to the use of the default server
36 ADD_DEFINITIONS(-DSCIQLOP_AMDA_SERVER="hybrid")
37 ADD_DEFINITIONS(-DSCIQLOP_AMDA_SERVER="hybrid")
37
38
38 set(sciqlop-amda_DIR "${CMAKE_SOURCE_DIR}/plugins/amda/cmake")
39 set(sciqlop-amda_DIR "${CMAKE_SOURCE_DIR}/plugins/amda/cmake")
39 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-amda_DIR}")
40 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-amda_DIR}")
40 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/amda")
41 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/amda")
41
42
42 # Temporary target to copy to plugins dir
43 # Temporary target to copy to plugins dir
43 find_package(sciqlop-mockplugin)
44 find_package(sciqlop-mockplugin)
44 find_package(sciqlop-amda)
45 find_package(sciqlop-amda)
45 ADD_CUSTOM_TARGET(plugins
46 ADD_CUSTOM_TARGET(plugins
46 COMMAND ${CMAKE_COMMAND} -E copy ${SCIQLOP-MOCKPLUGIN_LIBRARIES} "${LIBRARY_OUTPUT_PATH}/plugins/${SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME}"
47 COMMAND ${CMAKE_COMMAND} -E copy ${SCIQLOP-MOCKPLUGIN_LIBRARIES} "${LIBRARY_OUTPUT_PATH}/plugins/${SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME}"
47 COMMAND ${CMAKE_COMMAND} -E copy ${SCIQLOP-AMDA_LIBRARIES} "${LIBRARY_OUTPUT_PATH}/plugins/${SCIQLOP-AMDA_LIBRARIES_NAME}"
48 COMMAND ${CMAKE_COMMAND} -E copy ${SCIQLOP-AMDA_LIBRARIES} "${LIBRARY_OUTPUT_PATH}/plugins/${SCIQLOP-AMDA_LIBRARIES_NAME}"
48 )
49 )
49 ENDIF(BUILD_PLUGINS)
50 ENDIF(BUILD_PLUGINS)
50
51
51 # LOGGER
52 # LOGGER
52 set(QTLOGGING_INI_FILE "${CMAKE_SOURCE_DIR}/config/QtProject/qtlogging.ini")
53 set(QTLOGGING_INI_FILE "${CMAKE_SOURCE_DIR}/config/QtProject/qtlogging.ini")
53 FILE(COPY ${QTLOGGING_INI_FILE} DESTINATION ${CONFIG_OUTPUT_PATH})
54 FILE(COPY ${QTLOGGING_INI_FILE} DESTINATION ${CONFIG_OUTPUT_PATH})
54
55
55
56
56 #
57 #
57 # Code formatting
58 # Code formatting
58 #
59 #
59 # Vera++ exclusion files
60 # Vera++ exclusion files
60 LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/formatting/vera-exclusions/exclusions.txt)
61 LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/formatting/vera-exclusions/exclusions.txt)
61 #SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
62 #SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
62 INCLUDE ("cmake/sciqlop_formatting.cmake")
63 INCLUDE ("cmake/sciqlop_formatting.cmake")
63
64
64 #
65 #
65 # Documentation generation
66 # Documentation generation
66 #
67 #
67 INCLUDE ("cmake/sciqlop_doxygen.cmake")
68 INCLUDE ("cmake/sciqlop_doxygen.cmake")
68
69
69 #
70 #
70 # Source code analysis
71 # Source code analysis
71 #
72 #
72 INCLUDE ("cmake/sciqlop_code_analysis.cmake")
73 INCLUDE ("cmake/sciqlop_code_analysis.cmake")
73 INCLUDE ("cmake/sciqlop_code_cppcheck.cmake")
74 INCLUDE ("cmake/sciqlop_code_cppcheck.cmake")
@@ -1,45 +1,46
1 project('SciQLOP', 'cpp',default_options : ['cpp_std=c++14'])
1 project('SciQLOP', 'cpp',default_options : ['cpp_std=c++14'])
2
2
3 qt5 = import('qt5')
3 qt5 = import('qt5')
4 qt5core = dependency('qt5', modules : 'Core')
4 qt5core = dependency('qt5', modules : 'Core')
5 qt5widgets = dependency('qt5', modules : 'Widgets')
5 qt5widgets = dependency('qt5', modules : 'Widgets')
6 qt5gui = dependency('qt5', modules : 'Gui')
6 qt5gui = dependency('qt5', modules : 'Gui')
7 qt5svg = dependency('qt5', modules : 'Svg')
7 qt5svg = dependency('qt5', modules : 'Svg')
8 qt5xml = dependency('qt5', modules : 'Xml')
8 qt5xml = dependency('qt5', modules : 'Xml')
9 qt5network = dependency('qt5', modules : 'Network')
9 qt5network = dependency('qt5', modules : 'Network')
10 qt5printsupport = dependency('qt5', modules : 'PrintSupport')
10 qt5printsupport = dependency('qt5', modules : 'PrintSupport')
11 qt5test = dependency('qt5', modules : 'Test')
11 qt5test = dependency('qt5', modules : 'Test')
12
12
13 moc = find_program('moc-qt5','moc')
13 moc = find_program('moc-qt5','moc')
14 rcc = find_program('rcc-qt5','rcc')
14 rcc = find_program('rcc-qt5','rcc')
15
15
16 if build_machine.system()=='darwin'
16 if build_machine.system()=='darwin'
17 add_global_link_arguments('-headerpad_max_install_names', language : 'cpp')
17 add_global_link_arguments('-headerpad_max_install_names', language : 'cpp')
18 install_data('build_cfg/mac/sciqlopLOGO.icns', install_dir : 'Contents/Resources')
18 install_data('build_cfg/mac/sciqlopLOGO.icns', install_dir : 'Contents/Resources')
19 install_data('build_cfg/mac/Info.plist', install_dir : 'Contents')
19 install_data('build_cfg/mac/Info.plist', install_dir : 'Contents')
20 meson.add_install_script('build_cfg/mac/install_script.sh')
20 meson.add_install_script('build_cfg/mac/install_script.sh')
21 elif host_machine.system()=='windows'
21 elif host_machine.system()=='windows'
22 meson.add_install_script('build_cfg/windows/install_script.sh')
22 meson.add_install_script('build_cfg/windows/install_script.sh')
23 endif
23 endif
24
24
25 # Sets AMDA server that will be used during execution.
25 # Sets AMDA server that will be used during execution.
26 # Available values are:
26 # Available values are:
27 # - "default": default AMDA server
27 # - "default": default AMDA server
28 # - "amdatest": AMDA test server
28 # - "amdatest": AMDA test server
29 # - "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)
29 # - "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)
30 # - "localhost": use local AMDA server
30 # Any other value will lead to the use of the default server
31 # Any other value will lead to the use of the default server
31 add_project_arguments('-DSCIQLOP_AMDA_SERVER="hybrid"', language : 'cpp')
32 add_project_arguments('-DSCIQLOP_AMDA_SERVER="hybrid"', language : 'cpp')
32
33
33 subdir('core')
34 subdir('core')
34 subdir('gui')
35 subdir('gui')
35 subdir('app')
36 subdir('app')
36 subdir('plugins')
37 subdir('plugins')
37
38
38 cppcheck = find_program('cppcheck', required : false)
39 cppcheck = find_program('cppcheck', required : false)
39
40
40 if cppcheck.found()
41 if cppcheck.found()
41 run_target('cppcheck',
42 run_target('cppcheck',
42 command : [cppcheck, '--enable=all',
43 command : [cppcheck, '--enable=all',
43 '--project=' + join_paths(meson.build_root(), 'compile_commands.json')]
44 '--project=' + join_paths(meson.build_root(), 'compile_commands.json')]
44 )
45 )
45 endif
46 endif
@@ -1,78 +1,99
1 #include "AmdaServer.h"
1 #include "AmdaServer.h"
2
2
3 #include "AmdaDefs.h"
3 #include "AmdaDefs.h"
4
4
5 Q_LOGGING_CATEGORY(LOG_AmdaServer, "AmdaServer")
5 Q_LOGGING_CATEGORY(LOG_AmdaServer, "AmdaServer")
6
6
7 namespace {
7 namespace {
8
8
9 /// URL of the default AMDA server
9 /// URL of the default AMDA server
10 const auto AMDA_DEFAULT_SERVER_URL = QStringLiteral("amda.irap.omp.eu");
10 const auto AMDA_DEFAULT_SERVER_URL = QStringLiteral("amda.irap.omp.eu");
11
11
12 /// URL of the AMDA test server
12 /// URL of the AMDA test server
13 const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu");
13 const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu");
14
14
15 /// Port used for local server
16 const auto AMDA_LOCAL_SERVER_PORT = 6543;
17
18 /// URL of the local server
19 const auto AMDA_LOCAL_SERVER_URL
20 = QString{"localhost:%1"}.arg(QString::number(AMDA_LOCAL_SERVER_PORT));
21
15 /// Default AMDA server
22 /// Default AMDA server
16 struct AmdaDefaultServer : public AmdaServer {
23 struct AmdaDefaultServer : public AmdaServer {
17 public:
24 public:
18 QString name() const override { return QStringLiteral("AMDA (default)"); }
25 QString name() const override { return QStringLiteral("AMDA (default)"); }
19 QString url(const QVariantHash &properties) const override
26 QString url(const QVariantHash &properties) const override
20 {
27 {
21 Q_UNUSED(properties);
28 Q_UNUSED(properties);
22 return AMDA_DEFAULT_SERVER_URL;
29 return AMDA_DEFAULT_SERVER_URL;
23 }
30 }
24 };
31 };
25
32
26 /// Alternative AMDA server (tests)
33 /// Alternative AMDA server (tests)
27 struct AmdaTestServer : public AmdaServer {
34 struct AmdaTestServer : public AmdaServer {
28 public:
35 public:
29 QString name() const override { return QStringLiteral("AMDA (test)"); }
36 QString name() const override { return QStringLiteral("AMDA (test)"); }
30 QString url(const QVariantHash &properties) const override
37 QString url(const QVariantHash &properties) const override
31 {
38 {
32 Q_UNUSED(properties);
39 Q_UNUSED(properties);
33 return AMDA_TEST_SERVER_URL;
40 return AMDA_TEST_SERVER_URL;
34 }
41 }
35 };
42 };
36
43
37 /// Hybrid AMDA server: use both of default and test server.
44 /// Hybrid AMDA server: use both of default and test server.
38 /// The server used is relative to each product for which to retrieve url, according to its "server"
45 /// The server used is relative to each product for which to retrieve url, according to its "server"
39 /// property
46 /// property
40 struct AmdaHybridServer : public AmdaServer {
47 struct AmdaHybridServer : public AmdaServer {
41 public:
48 public:
42 QString name() const override { return QStringLiteral("AMDA (hybrid)"); }
49 QString name() const override { return QStringLiteral("AMDA (hybrid)"); }
43 QString url(const QVariantHash &properties) const override
50 QString url(const QVariantHash &properties) const override
44 {
51 {
45 // Reads "server" property to determine which server url to use
52 // Reads "server" property to determine which server url to use
46 auto server = properties.value(AMDA_SERVER_KEY).toString();
53 auto server = properties.value(AMDA_SERVER_KEY).toString();
47 return server == QString{"amdatest"} ? AMDA_TEST_SERVER_URL : AMDA_DEFAULT_SERVER_URL;
54 return server == QString{"amdatest"} ? AMDA_TEST_SERVER_URL : AMDA_DEFAULT_SERVER_URL;
48 }
55 }
49 };
56 };
50
57
58 /// Local AMDA server: use local python server to simulate AMDA requests
59 struct AmdaLocalServer : public AmdaServer {
60 public:
61 QString name() const override { return AMDA_LOCAL_SERVER_URL; }
62 QString url(const QVariantHash &properties) const override
63 {
64 Q_UNUSED(properties);
65 return AMDA_LOCAL_SERVER_URL;
66 }
67 };
68
51 /// @return an AMDA server instance created from the name of the server passed in parameter. If the
69 /// @return an AMDA server instance created from the name of the server passed in parameter. If the
52 /// name does not match any known server, a default server instance is created
70 /// name does not match any known server, a default server instance is created
53 std::unique_ptr<AmdaServer> createInstance(const QString &server)
71 std::unique_ptr<AmdaServer> createInstance(const QString &server)
54 {
72 {
55 if (server == QString{"amdatest"}) {
73 if (server == QString{"amdatest"}) {
56 return std::make_unique<AmdaTestServer>();
74 return std::make_unique<AmdaTestServer>();
57 }
75 }
58 else if (server == QString{"hybrid"}) {
76 else if (server == QString{"hybrid"}) {
59 return std::make_unique<AmdaHybridServer>();
77 return std::make_unique<AmdaHybridServer>();
60 }
78 }
79 else if (server == QString{"localhost"}) {
80 return std::make_unique<AmdaLocalServer>();
81 }
61 else {
82 else {
62 if (server != QString{"default"}) {
83 if (server != QString{"default"}) {
63 qCWarning(LOG_AmdaServer())
84 qCWarning(LOG_AmdaServer())
64 << QObject::tr("Unknown server '%1': default AMDA server will be used").arg(server);
85 << QObject::tr("Unknown server '%1': default AMDA server will be used").arg(server);
65 }
86 }
66
87
67 return std::make_unique<AmdaDefaultServer>();
88 return std::make_unique<AmdaDefaultServer>();
68 }
89 }
69 }
90 }
70
91
71 } // namespace
92 } // namespace
72
93
73 AmdaServer &AmdaServer::instance()
94 AmdaServer &AmdaServer::instance()
74 {
95 {
75 // Creates instance depending on the SCIQLOP_AMDA_SERVER value at compile time
96 // Creates instance depending on the SCIQLOP_AMDA_SERVER value at compile time
76 static auto instance = createInstance(SCIQLOP_AMDA_SERVER);
97 static auto instance = createInstance(SCIQLOP_AMDA_SERVER);
77 return *instance;
98 return *instance;
78 }
99 }
General Comments 0
You need to be logged in to leave comments. Login now