##// END OF EJS Templates
Creates JSON parser
Alexandre Leroux -
r354:b3b541ccaa5a
parent child
Show More
@@ -0,0 +1,23
1 #ifndef SCIQLOP_AMDAPARSER_H
2 #define SCIQLOP_AMDAPARSER_H
3
4 #include "AmdaGlobal.h"
5
6 #include <QLoggingCategory>
7
8 #include <memory>
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaParser)
11
12 class DataSourceItem;
13
14 struct SCIQLOP_AMDA_EXPORT AmdaParser {
15 /**
16 * Creates a data source tree from a JSON file
17 * @param filePath the path of the JSON file to read
18 * @return the root of the created data source tree, nullptr if the file couldn't be parsed
19 */
20 static std::unique_ptr<DataSourceItem> readJson(const QString &filePath) noexcept;
21 };
22
23 #endif // SCIQLOP_AMDAPARSER_H
@@ -0,0 +1,11
1 #include "AmdaParser.h"
2
3 #include <DataSource/DataSourceItem.h>
4
5 Q_LOGGING_CATEGORY(LOG_AmdaParser, "AmdaParser")
6
7 std::unique_ptr<DataSourceItem> AmdaParser::readJson(const QString &filePath) noexcept
8 {
9 /// @todo ALX
10 return nullptr;
11 }
@@ -1,32 +1,39
1 1 #include "AmdaPlugin.h"
2 #include "AmdaParser.h"
2 3
3 4 #include <DataSource/DataSourceController.h>
5 #include <DataSource/DataSourceItem.h>
4 6
5 7 #include <SqpApplication.h>
6 8
7 9 Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin")
8 10
9 11 namespace {
10 12
11 13 /// Name of the data source
12 14 const auto DATA_SOURCE_NAME = QStringLiteral("AMDA");
13 15
14 16 /// Path of the file used to generate the data source item for AMDA
15 17 const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSample.json");
16 18
17 19 } // namespace
18 20
19 21 void AmdaPlugin::initialize()
20 22 {
21 23 if (auto app = sqpApp) {
22 24 // Registers to the data source controller
23 25 auto &dataSourceController = app->dataSourceController();
24 26 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
25 27
26 28 // Sets data source tree
27 /// @todo ALX
29 if (auto dataSourceItem = AmdaParser::readJson(JSON_FILE_PATH)) {
30 dataSourceController.setDataSourceItem(dataSourceUid, std::move(dataSourceItem));
31 }
32 else {
33 qCCritical(LOG_AmdaPlugin()) << tr("No data source item could be generated for AMDA");
34 }
28 35 }
29 36 else {
30 37 qCWarning(LOG_AmdaPlugin()) << tr("Can't access to SciQlop application");
31 38 }
32 39 }
General Comments 0
You need to be logged in to leave comments. Login now