##// END OF EJS Templates
Inits Amda provider
Alexandre Leroux -
r377:20d934b9b94e
parent child
Show More
@@ -0,0 +1,31
1 #ifndef SCIQLOP_AMDAPROVIDER_H
2 #define SCIQLOP_AMDAPROVIDER_H
3
4 #include "AmdaGlobal.h"
5
6 #include <Common/spimpl.h>
7
8 #include <Data/IDataProvider.h>
9
10 #include <QLoggingCategory>
11
12
13 Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaProvider)
14
15 /**
16 * @brief The AmdaProvider class is an example of how a data provider can generate data
17 */
18 class SCIQLOP_AMDA_EXPORT AmdaProvider : public IDataProvider {
19 public:
20 explicit AmdaProvider();
21
22 void requestDataLoading(QUuid token, const QVector<SqpDateTime> &dateTimeList) override;
23
24 private:
25 void retrieveData(QUuid token, const DataProviderParameters &parameters) const;
26
27 class AmdaProviderPrivate;
28 spimpl::unique_impl_ptr<AmdaProviderPrivate> impl;
29 };
30
31 #endif // SCIQLOP_AMDAPROVIDER_H
@@ -0,0 +1,23
1 #include "AmdaProvider.h"
2
3 Q_LOGGING_CATEGORY(LOG_AmdaProvider, "AmdaProvider")
4
5 struct AmdaProvider::AmdaProviderPrivate {
6 };
7
8 AmdaProvider::AmdaProvider() : impl{spimpl::make_unique_impl<AmdaProviderPrivate>()}
9 {
10 }
11
12 void AmdaProvider::requestDataLoading(QUuid token, const QVector<SqpDateTime> &dateTimeList)
13 {
14 // NOTE: Try to use multithread if possible
15 for (const auto &dateTime : dateTimeList) {
16 retrieveData(token, DataProviderParameters{dateTime});
17 }
18 }
19
20 void AmdaProvider::retrieveData(QUuid token, const DataProviderParameters &parameters) const
21 {
22 /// @todo ALX
23 }
@@ -1,39 +1,42
1 1 #include "AmdaPlugin.h"
2 2 #include "AmdaParser.h"
3 3
4 4 #include <DataSource/DataSourceController.h>
5 5 #include <DataSource/DataSourceItem.h>
6 6
7 7 #include <SqpApplication.h>
8 8
9 9 Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin")
10 10
11 11 namespace {
12 12
13 13 /// Name of the data source
14 14 const auto DATA_SOURCE_NAME = QStringLiteral("AMDA");
15 15
16 16 /// Path of the file used to generate the data source item for AMDA
17 17 const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSample.json");
18 18
19 19 } // namespace
20 20
21 21 void AmdaPlugin::initialize()
22 22 {
23 23 if (auto app = sqpApp) {
24 24 // Registers to the data source controller
25 25 auto &dataSourceController = app->dataSourceController();
26 26 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
27 27
28 28 // Sets data source tree
29 29 if (auto dataSourceItem = AmdaParser::readJson(JSON_FILE_PATH)) {
30 30 dataSourceController.setDataSourceItem(dataSourceUid, std::move(dataSourceItem));
31 31 }
32 32 else {
33 33 qCCritical(LOG_AmdaPlugin()) << tr("No data source item could be generated for AMDA");
34 34 }
35
36 // Sets data provider
37 dataSourceController.setDataProvider(dataSourceUid, std::make_unique<AmdaProvider>());
35 38 }
36 39 else {
37 40 qCWarning(LOG_AmdaPlugin()) << tr("Can't access to SciQlop application");
38 41 }
39 42 }
General Comments 0
You need to be logged in to leave comments. Login now