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