##// 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,6 +1,8
1 #include "AmdaPlugin.h"
1 #include "AmdaPlugin.h"
2 #include "AmdaParser.h"
2
3
3 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceController.h>
5 #include <DataSource/DataSourceItem.h>
4
6
5 #include <SqpApplication.h>
7 #include <SqpApplication.h>
6
8
@@ -24,7 +26,12 void AmdaPlugin::initialize()
24 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
26 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
25
27
26 // Sets data source tree
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 else {
36 else {
30 qCWarning(LOG_AmdaPlugin()) << tr("Can't access to SciQlop application");
37 qCWarning(LOG_AmdaPlugin()) << tr("Can't access to SciQlop application");
General Comments 0
You need to be logged in to leave comments. Login now