From a08e6992e14608a5306ab67232e3f5b9492dedfc 2017-08-17 08:24:19 From: Alexandre Leroux Date: 2017-08-17 08:24:19 Subject: [PATCH] Creates enum that represents the value types that can be read in AMDA This enum is passed in parameter of the reading method to parse the result file according to it --- diff --git a/plugins/amda/include/AmdaResultParser.h b/plugins/amda/include/AmdaResultParser.h index 8c4bc61..0d590d5 100644 --- a/plugins/amda/include/AmdaResultParser.h +++ b/plugins/amda/include/AmdaResultParser.h @@ -12,8 +12,10 @@ class IDataSeries; Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaResultParser) struct SCIQLOP_AMDA_EXPORT AmdaResultParser { + enum class ValueType { SCALAR, VECTOR, UNKNOWN }; - static std::shared_ptr readTxt(const QString &filePath) noexcept; + static std::shared_ptr readTxt(const QString &filePath, + ValueType valueType) noexcept; }; #endif // SCIQLOP_AMDARESULTPARSER_H diff --git a/plugins/amda/src/AmdaResultParser.cpp b/plugins/amda/src/AmdaResultParser.cpp index ba5b907..ddc87f6 100644 --- a/plugins/amda/src/AmdaResultParser.cpp +++ b/plugins/amda/src/AmdaResultParser.cpp @@ -125,8 +125,15 @@ QPair, QVector > readResults(QTextStream &stream) } // namespace -std::shared_ptr AmdaResultParser::readTxt(const QString &filePath) noexcept +std::shared_ptr AmdaResultParser::readTxt(const QString &filePath, + ValueType valueType) noexcept { + if (valueType == ValueType::UNKNOWN) { + qCCritical(LOG_AmdaResultParser()) + << QObject::tr("Can't retrieve AMDA data: the type of values to be read is unknown"); + return nullptr; + } + QFile file{filePath}; if (!file.open(QFile::ReadOnly | QIODevice::Text)) {