diff --git a/cmake/sciqlop_applications.cmake b/cmake/sciqlop_applications.cmake index fcaba8b..3509844 100644 --- a/cmake/sciqlop_applications.cmake +++ b/cmake/sciqlop_applications.cmake @@ -27,6 +27,15 @@ IF(BUILD_PLUGINS) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-mockplugin_DIR}") ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/mockplugin") + # Sets AMDA server that will be used during execution. + # Available values are: + # - "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") + set(sciqlop-amda_DIR "${CMAKE_SOURCE_DIR}/plugins/amda/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-amda_DIR}") ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/amda") diff --git a/meson.build b/meson.build index 8ee42fa..5a77de9 100644 --- a/meson.build +++ b/meson.build @@ -22,6 +22,15 @@ elif host_machine.system()=='windows' meson.add_install_script('build_cfg/windows/install_script.sh') endif +# Sets AMDA server that will be used during execution. +# Available values are: +# - "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') + subdir('core') subdir('gui') subdir('app') diff --git a/plugins/amda/CMakeLists.txt b/plugins/amda/CMakeLists.txt index 1b66326..dcce263 100644 --- a/plugins/amda/CMakeLists.txt +++ b/plugins/amda/CMakeLists.txt @@ -92,7 +92,7 @@ SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPAMDA_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) # Vera++ exclusion files -#LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) +LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) # diff --git a/plugins/amda/include/AmdaPlugin.h b/plugins/amda/include/AmdaPlugin.h index 199f9ea..aeca5d2 100644 --- a/plugins/amda/include/AmdaPlugin.h +++ b/plugins/amda/include/AmdaPlugin.h @@ -11,8 +11,8 @@ Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaPlugin) -#ifndef PLUGIN_JSON_FILE_PATH -#define PLUGIN_JSON_FILE_PATH "amda.json" +#ifndef SCIQLOP_PLUGIN_JSON_FILE_PATH +#define SCIQLOP_PLUGIN_JSON_FILE_PATH "amda.json" #endif class DataSourceItem; @@ -20,7 +20,7 @@ class DataSourceItem; class SCIQLOP_AMDA_EXPORT AmdaPlugin : public QObject, public IPlugin { Q_OBJECT Q_INTERFACES(IPlugin) - Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE PLUGIN_JSON_FILE_PATH) + Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE SCIQLOP_PLUGIN_JSON_FILE_PATH) public: /// @sa IPlugin::initialize() void initialize() override; diff --git a/plugins/amda/include/AmdaProvider.h b/plugins/amda/include/AmdaProvider.h index 3736954..6a57c0d 100644 --- a/plugins/amda/include/AmdaProvider.h +++ b/plugins/amda/include/AmdaProvider.h @@ -27,10 +27,6 @@ public: void requestDataAborting(QUuid acqIdentifier) override; -private slots: - void onReplyDownloadProgress(QUuid acqIdentifier, - std::shared_ptr networkRequest, double progress); - private: void retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data); @@ -39,6 +35,10 @@ private: std::map, double> > m_AcqIdToRequestProgressMap; + +private slots: + void onReplyDownloadProgress(QUuid acqIdentifier, + std::shared_ptr networkRequest, double progress); }; #endif // SCIQLOP_AMDAPROVIDER_H diff --git a/plugins/amda/include/AmdaResultParserDefs.h b/plugins/amda/include/AmdaResultParserDefs.h index 410201a..5e3d6d8 100644 --- a/plugins/amda/include/AmdaResultParserDefs.h +++ b/plugins/amda/include/AmdaResultParserDefs.h @@ -46,6 +46,9 @@ extern const QString VALUES_UNIT_PROPERTY; /// ... - Units : m/s - ... extern const QRegularExpression DEFAULT_X_AXIS_UNIT_REGEX; +/// Alternative regex to find x-axis unit in a line +extern const QRegularExpression ALTERNATIVE_X_AXIS_UNIT_REGEX; + /// Regex to find end time of data in a line for a spectrogram extern const QRegularExpression SPECTROGRAM_END_TIME_REGEX; diff --git a/plugins/amda/include/AmdaServer.h b/plugins/amda/include/AmdaServer.h new file mode 100644 index 0000000..1826bdb --- /dev/null +++ b/plugins/amda/include/AmdaServer.h @@ -0,0 +1,35 @@ +#ifndef SCIQLOP_AMDASERVER_H +#define SCIQLOP_AMDASERVER_H + +#include + +#include + +Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaServer) + +// Directive used to determine the active AMDA server +#ifndef SCIQLOP_AMDA_SERVER +#define SCIQLOP_AMDA_SERVER "default" +#endif + +/** + * @brief The AmdaServer class represents the server used to retrieve AMDA data (singleton). + * + * The server instance is initialized at compile time, as defined by the AMDA_SERVER value. + */ +class AmdaServer { +public: + /// @return the unique instance of the AMDA server + static AmdaServer &instance(); + + virtual ~AmdaServer() noexcept = default; + + /// @return the name of the server + virtual QString name() const = 0; + + /// @param properties used to generate url + /// @return the url of the server (used to retrieve data) + virtual QString url(const QVariantHash &properties = {}) const = 0; +}; + +#endif // SCIQLOP_AMDASERVER_H diff --git a/plugins/amda/meson.build b/plugins/amda/meson.build index 7f2e2c3..7728623 100644 --- a/plugins/amda/meson.build +++ b/plugins/amda/meson.build @@ -11,7 +11,8 @@ amdaplugin_sources = [ 'src/AmdaProvider.cpp', 'src/AmdaResultParser.cpp', 'src/AmdaResultParserDefs.cpp', - 'src/AmdaResultParserHelper.cpp' + 'src/AmdaResultParserHelper.cpp', + 'src/AmdaServer.cpp' ] amdaplugin_ui_files = [] @@ -24,7 +25,7 @@ amdaplugin_inc = include_directories(['include', '../../plugin/include']) moc_gen = generator(moc, output : 'moc_@BASENAME@.cpp', arguments : ['@INPUT@', - '-DPLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/amda/resources/amda.json"', + '-DSCIQLOP_PLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/amda/resources/amda.json"', '-I', meson.current_source_dir()+'/include', '-I', meson.current_source_dir()+'/../../plugin/include', '-o', '@OUTPUT@']) diff --git a/plugins/amda/src/AmdaPlugin.cpp b/plugins/amda/src/AmdaPlugin.cpp index 0a033a9..85c51a6 100644 --- a/plugins/amda/src/AmdaPlugin.cpp +++ b/plugins/amda/src/AmdaPlugin.cpp @@ -2,6 +2,7 @@ #include "AmdaDefs.h" #include "AmdaParser.h" #include "AmdaProvider.h" +#include "AmdaServer.h" #include #include @@ -13,9 +14,6 @@ Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin") namespace { -/// Name of the data source -const auto DATA_SOURCE_NAME = QStringLiteral("AMDA"); - /// Path of the file used to generate the data source item for AMDA const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSampleV3.json"); @@ -33,7 +31,7 @@ void associateActions(DataSourceItem &item, const QUuid &dataSourceUid) const auto itemType = item.type(); if (itemType == DataSourceItemType::PRODUCT || itemType == DataSourceItemType::COMPONENT) { // Adds plugin name to item metadata - item.setData(DataSourceItem::PLUGIN_DATA_KEY, DATA_SOURCE_NAME); + item.setData(DataSourceItem::PLUGIN_DATA_KEY, AmdaServer::instance().name()); // Adds load action auto actionLabel = QObject::tr( @@ -54,14 +52,17 @@ void associateActions(DataSourceItem &item, const QUuid &dataSourceUid) void AmdaPlugin::initialize() { if (auto app = sqpApp) { + auto dataSourceName = AmdaServer::instance().name(); + // Registers to the data source controller auto &dataSourceController = app->dataSourceController(); - auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME); + auto dataSourceUid = dataSourceController.registerDataSource(dataSourceName); // Sets data source tree if (auto dataSourceItem = AmdaParser::readJson(JSON_FILE_PATH)) { - associateActions(*dataSourceItem, dataSourceUid); + dataSourceItem->setData(DataSourceItem::NAME_DATA_KEY, dataSourceName); + associateActions(*dataSourceItem, dataSourceUid); dataSourceController.setDataSourceItem(dataSourceUid, std::move(dataSourceItem)); } else { diff --git a/plugins/amda/src/AmdaProvider.cpp b/plugins/amda/src/AmdaProvider.cpp index 1d91a89..63e2ffc 100644 --- a/plugins/amda/src/AmdaProvider.cpp +++ b/plugins/amda/src/AmdaProvider.cpp @@ -1,6 +1,7 @@ #include "AmdaProvider.h" #include "AmdaDefs.h" #include "AmdaResultParser.h" +#include "AmdaServer.h" #include #include @@ -17,12 +18,6 @@ Q_LOGGING_CATEGORY(LOG_AmdaProvider, "AmdaProvider") namespace { -/// URL of the default AMDA server -const auto AMDA_SERVER_URL = QStringLiteral("amda.irap.omp.eu"); - -/// URL of the AMDA test server -const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu"); - /// URL format for a request on AMDA server. The parameters are as follows: /// - %1: server URL /// - %2: start date @@ -44,18 +39,6 @@ QString dateFormat(double sqpRange) noexcept return dateTime.toString(AMDA_TIME_FORMAT); } -/// Returns the URL of the AMDA server queried for requests, depending on the type of server passed -/// as a parameter -QString serverURL(const QString &server) -{ - if (server == QString{"amdatest"}) { - return AMDA_TEST_SERVER_URL; - } - else { - return AMDA_SERVER_URL; - } -} - AmdaResultParser::ValueType valueType(const QString &valueType) { if (valueType == QStringLiteral("scalar")) { @@ -190,9 +173,6 @@ void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa // scalar, vector... auto productValueType = valueType(data.value(AMDA_DATA_TYPE_KEY).toString()); - // Gets the server being queried to retrieve the product. It's then used to set the server URL - auto productServer = data.value(AMDA_SERVER_KEY).toString(); - // /////////// // // Creates URL // // /////////// // @@ -200,8 +180,9 @@ void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa auto startDate = dateFormat(dateTime.m_TStart); auto endDate = dateFormat(dateTime.m_TEnd); - auto url = QUrl{ - QString{AMDA_URL_FORMAT}.arg(serverURL(productServer), startDate, endDate, productId)}; + QVariantHash urlProperties{{AMDA_SERVER_KEY, data.value(AMDA_SERVER_KEY)}}; + auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(AmdaServer::instance().url(urlProperties), + startDate, endDate, productId)}; qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url; auto tempFile = std::make_shared(); diff --git a/plugins/amda/src/AmdaResultParserDefs.cpp b/plugins/amda/src/AmdaResultParserDefs.cpp index 37c2cf9..311ebe1 100644 --- a/plugins/amda/src/AmdaResultParserDefs.cpp +++ b/plugins/amda/src/AmdaResultParserDefs.cpp @@ -11,9 +11,17 @@ const QString X_AXIS_UNIT_PROPERTY = QStringLiteral("xAxisUnit"); const QString Y_AXIS_UNIT_PROPERTY = QStringLiteral("yAxisUnit"); const QString VALUES_UNIT_PROPERTY = QStringLiteral("valuesUnit"); +namespace { + +const auto PARAMETER_UNITS_REGEX + = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.*)")}; +} + const QRegularExpression DEFAULT_X_AXIS_UNIT_REGEX = QRegularExpression{QStringLiteral("-\\s*Units\\s*:\\s*(.+?)\\s*-")}; +const QRegularExpression ALTERNATIVE_X_AXIS_UNIT_REGEX = PARAMETER_UNITS_REGEX; + const QRegularExpression SPECTROGRAM_END_TIME_REGEX = QRegularExpression{QStringLiteral("\\s*INTERVAL_STOP\\s*:\\s*(.*)")}; @@ -38,5 +46,4 @@ const QRegularExpression SPECTROGRAM_START_TIME_REGEX const QRegularExpression SPECTROGRAM_Y_AXIS_UNIT_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_TABLE_UNITS\\[0\\]\\s*:\\s*(.*)")}; -const QRegularExpression SPECTROGRAM_VALUES_UNIT_REGEX - = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.*)")}; +const QRegularExpression SPECTROGRAM_VALUES_UNIT_REGEX = PARAMETER_UNITS_REGEX; diff --git a/plugins/amda/src/AmdaResultParserHelper.cpp b/plugins/amda/src/AmdaResultParserHelper.cpp index a483800..64ab7de 100644 --- a/plugins/amda/src/AmdaResultParserHelper.cpp +++ b/plugins/amda/src/AmdaResultParserHelper.cpp @@ -136,7 +136,7 @@ void tryReadResult(std::vector &xAxisData, std::vector &valuesDa * @param properties the properties map in which to put the property extracted from the line * @param key the key to which the property is added in the properties map * @param line the line to read to extract the property - * @param regex the expected regex to extract the property. If the line matches this regex, the + * @param regexes the expected regexes to extract the property. If the line matches one regex, the * property is generated * @param fun the function used to generate the property * @return true if the property could be generated, false if the line does not match the regex, or @@ -144,18 +144,24 @@ void tryReadResult(std::vector &xAxisData, std::vector &valuesDa */ template bool tryReadProperty(Properties &properties, const QString &key, const QString &line, - const QRegularExpression ®ex, GeneratePropertyFun fun) + const std::vector ®exes, GeneratePropertyFun fun) { if (properties.contains(key)) { return false; } - auto match = regex.match(line); - if (match.hasMatch()) { - properties.insert(key, fun(match)); + // Searches for a match among all possible regexes + auto hasMatch = false; + for (auto regexIt = regexes.cbegin(), end = regexes.cend(); regexIt != end && !hasMatch; + ++regexIt) { + auto match = regexIt->match(line); + auto hasMatch = match.hasMatch(); + if (hasMatch) { + properties.insert(key, fun(match)); + } } - return match.hasMatch(); + return hasMatch; } /** @@ -163,9 +169,9 @@ bool tryReadProperty(Properties &properties, const QString &key, const QString & * @sa tryReadProperty() */ bool tryReadDate(Properties &properties, const QString &key, const QString &line, - const QRegularExpression ®ex, bool timeUnit = false) + const std::vector ®exes, bool timeUnit = false) { - return tryReadProperty(properties, key, line, regex, [timeUnit](const auto &match) { + return tryReadProperty(properties, key, line, regexes, [timeUnit](const auto &match) { return QVariant::fromValue(doubleDate(match.captured(1))); }); } @@ -175,9 +181,9 @@ bool tryReadDate(Properties &properties, const QString &key, const QString &line * @sa tryReadProperty() */ bool tryReadDouble(Properties &properties, const QString &key, const QString &line, - const QRegularExpression ®ex) + const std::vector ®exes) { - return tryReadProperty(properties, key, line, regex, [](const auto &match) { + return tryReadProperty(properties, key, line, regexes, [](const auto &match) { bool ok; // If the value can't be converted to double, it is set to NaN @@ -196,9 +202,10 @@ bool tryReadDouble(Properties &properties, const QString &key, const QString &li * @sa tryReadProperty() */ bool tryReadDoubles(Properties &properties, const QString &key, const QString &line, - const QRegularExpression ®ex, const QString &sep = QStringLiteral(",")) + const std::vector ®exes, + const QString &sep = QStringLiteral(",")) { - return tryReadProperty(properties, key, line, regex, [sep](const auto &match) { + return tryReadProperty(properties, key, line, regexes, [sep](const auto &match) { std::vector doubleValues{}; // If the value can't be converted to double, it is set to NaN @@ -223,9 +230,9 @@ bool tryReadDoubles(Properties &properties, const QString &key, const QString &l * @sa tryReadProperty() */ bool tryReadUnit(Properties &properties, const QString &key, const QString &line, - const QRegularExpression ®ex, bool timeUnit = false) + const std::vector ®exes, bool timeUnit = false) { - return tryReadProperty(properties, key, line, regex, [timeUnit](const auto &match) { + return tryReadProperty(properties, key, line, regexes, [timeUnit](const auto &match) { return QVariant::fromValue(Unit{match.captured(1), timeUnit}); }); } @@ -251,7 +258,8 @@ std::shared_ptr ScalarParserHelper::createSeries() void ScalarParserHelper::readPropertyLine(const QString &line) { - tryReadUnit(m_Properties, X_AXIS_UNIT_PROPERTY, line, DEFAULT_X_AXIS_UNIT_REGEX, true); + tryReadUnit(m_Properties, X_AXIS_UNIT_PROPERTY, line, + {DEFAULT_X_AXIS_UNIT_REGEX, ALTERNATIVE_X_AXIS_UNIT_REGEX}, true); } void ScalarParserHelper::readResultLine(const QString &line) @@ -321,46 +329,46 @@ void SpectrogramParserHelper::readPropertyLine(const QString &line) // values unit [&] { return tryReadUnit(m_Properties, VALUES_UNIT_PROPERTY, line, - SPECTROGRAM_VALUES_UNIT_REGEX); + {SPECTROGRAM_VALUES_UNIT_REGEX}); }, // y-axis unit [&] { return tryReadUnit(m_Properties, Y_AXIS_UNIT_PROPERTY, line, - SPECTROGRAM_Y_AXIS_UNIT_REGEX); + {SPECTROGRAM_Y_AXIS_UNIT_REGEX}); }, // min sampling [&] { return tryReadDouble(m_Properties, MIN_SAMPLING_PROPERTY, line, - SPECTROGRAM_MIN_SAMPLING_REGEX); + {SPECTROGRAM_MIN_SAMPLING_REGEX}); }, // max sampling [&] { return tryReadDouble(m_Properties, MAX_SAMPLING_PROPERTY, line, - SPECTROGRAM_MAX_SAMPLING_REGEX); + {SPECTROGRAM_MAX_SAMPLING_REGEX}); }, // fill value [&] { return tryReadDouble(m_Properties, FILL_VALUE_PROPERTY, line, - SPECTROGRAM_FILL_VALUE_REGEX); + {SPECTROGRAM_FILL_VALUE_REGEX}); }, // min bounds of each band [&] { return tryReadDoubles(m_Properties, MIN_BANDS_PROPERTY, line, - SPECTROGRAM_MIN_BANDS_REGEX); + {SPECTROGRAM_MIN_BANDS_REGEX}); }, // max bounds of each band [&] { return tryReadDoubles(m_Properties, MAX_BANDS_PROPERTY, line, - SPECTROGRAM_MAX_BANDS_REGEX); + {SPECTROGRAM_MAX_BANDS_REGEX}); }, // start time of data [&] { return tryReadDate(m_Properties, START_TIME_PROPERTY, line, - SPECTROGRAM_START_TIME_REGEX); + {SPECTROGRAM_START_TIME_REGEX}); }, // end time of data [&] { - return tryReadDate(m_Properties, END_TIME_PROPERTY, line, SPECTROGRAM_END_TIME_REGEX); + return tryReadDate(m_Properties, END_TIME_PROPERTY, line, {SPECTROGRAM_END_TIME_REGEX}); }}; for (auto function : functions) { @@ -407,7 +415,8 @@ std::shared_ptr VectorParserHelper::createSeries() void VectorParserHelper::readPropertyLine(const QString &line) { - tryReadUnit(m_Properties, X_AXIS_UNIT_PROPERTY, line, DEFAULT_X_AXIS_UNIT_REGEX, true); + tryReadUnit(m_Properties, X_AXIS_UNIT_PROPERTY, line, + {DEFAULT_X_AXIS_UNIT_REGEX, ALTERNATIVE_X_AXIS_UNIT_REGEX}, true); } void VectorParserHelper::readResultLine(const QString &line) diff --git a/plugins/amda/src/AmdaServer.cpp b/plugins/amda/src/AmdaServer.cpp new file mode 100644 index 0000000..66c11cf --- /dev/null +++ b/plugins/amda/src/AmdaServer.cpp @@ -0,0 +1,99 @@ +#include "AmdaServer.h" + +#include "AmdaDefs.h" + +Q_LOGGING_CATEGORY(LOG_AmdaServer, "AmdaServer") + +namespace { + +/// URL of the default AMDA server +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: + QString name() const override { return QStringLiteral("AMDA (default)"); } + QString url(const QVariantHash &properties) const override + { + Q_UNUSED(properties); + return AMDA_DEFAULT_SERVER_URL; + } +}; + +/// Alternative AMDA server (tests) +struct AmdaTestServer : public AmdaServer { +public: + QString name() const override { return QStringLiteral("AMDA (test)"); } + QString url(const QVariantHash &properties) const override + { + Q_UNUSED(properties); + return AMDA_TEST_SERVER_URL; + } +}; + +/// Hybrid AMDA server: use both of default and test server. +/// The server used is relative to each product for which to retrieve url, according to its "server" +/// property +struct AmdaHybridServer : public AmdaServer { +public: + QString name() const override { return QStringLiteral("AMDA (hybrid)"); } + QString url(const QVariantHash &properties) const override + { + // Reads "server" property to determine which server url to use + auto server = properties.value(AMDA_SERVER_KEY).toString(); + return server == QString{"amdatest"} ? AMDA_TEST_SERVER_URL : AMDA_DEFAULT_SERVER_URL; + } +}; + +/// 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) +{ + if (server == QString{"amdatest"}) { + return std::make_unique(); + } + 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()) + << QObject::tr("Unknown server '%1': default AMDA server will be used").arg(server); + } + + return std::make_unique(); + } +} + +} // namespace + +AmdaServer &AmdaServer::instance() +{ + // Creates instance depending on the SCIQLOP_AMDA_SERVER value at compile time + static auto instance = createInstance(SCIQLOP_AMDA_SERVER); + return *instance; +} diff --git a/plugins/amda/vera-exclusions/exclusions.txt b/plugins/amda/vera-exclusions/exclusions.txt new file mode 100644 index 0000000..0a5db22 --- /dev/null +++ b/plugins/amda/vera-exclusions/exclusions.txt @@ -0,0 +1,5 @@ +AmdaResultParser\.h:\d+:.*IPSIS_S01.* +AmdaResultParserHelper\.h:\d+:.*IPSIS_S01.* + +AmdaProvider\.cpp:\d+:.*IPSIS_S04_VARIABLE.*found: QStringLiteral +AmdaResultParserHelper\.cpp:\d+:.*IPSIS_S04_VARIABLE.*found: QT_VERSION_CHECK \ No newline at end of file