##// 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 #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
7 Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin")
9 Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin")
8
10
9 namespace {
11 namespace {
10
12
11 /// Name of the data source
13 /// Name of the data source
12 const auto DATA_SOURCE_NAME = QStringLiteral("AMDA");
14 const auto DATA_SOURCE_NAME = QStringLiteral("AMDA");
13
15
14 /// Path of the file used to generate the data source item for AMDA
16 /// Path of the file used to generate the data source item for AMDA
15 const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSample.json");
17 const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSample.json");
16
18
17 } // namespace
19 } // namespace
18
20
19 void AmdaPlugin::initialize()
21 void AmdaPlugin::initialize()
20 {
22 {
21 if (auto app = sqpApp) {
23 if (auto app = sqpApp) {
22 // Registers to the data source controller
24 // Registers to the data source controller
23 auto &dataSourceController = app->dataSourceController();
25 auto &dataSourceController = app->dataSourceController();
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");
31 }
38 }
32 }
39 }
General Comments 0
You need to be logged in to leave comments. Login now