@@ -1,70 +1,72 | |||
|
1 | 1 | #ifndef SCIQLOP_IDATAPROVIDER_H |
|
2 | 2 | #define SCIQLOP_IDATAPROVIDER_H |
|
3 | 3 | |
|
4 | 4 | #include <memory> |
|
5 | 5 | |
|
6 | 6 | #include <QObject> |
|
7 | 7 | #include <QUuid> |
|
8 | 8 | |
|
9 | 9 | #include <Common/MetaTypes.h> |
|
10 | 10 | |
|
11 | 11 | #include <Data/SqpDateTime.h> |
|
12 | 12 | |
|
13 | #include <functional> | |
|
14 | ||
|
13 | 15 | class DataProviderParameters; |
|
14 | 16 | class IDataSeries; |
|
15 | 17 | class QNetworkReply; |
|
16 | 18 | class QNetworkRequest; |
|
17 | 19 | |
|
18 | 20 | /** |
|
19 | 21 | * @brief The IDataProvider interface aims to declare a data provider. |
|
20 | 22 | * |
|
21 | 23 | * A data provider is an entity that generates data and returns it according to various parameters |
|
22 | 24 | * (time interval, product to retrieve the data, etc.) |
|
23 | 25 | * |
|
24 | 26 | * @sa IDataSeries |
|
25 | 27 | */ |
|
26 | 28 | class IDataProvider : public QObject { |
|
27 | 29 | |
|
28 | 30 | Q_OBJECT |
|
29 | 31 | public: |
|
30 | 32 | virtual ~IDataProvider() noexcept = default; |
|
31 | 33 | |
|
32 | 34 | /** |
|
33 | 35 | * @brief requestDataLoading provide datas for the data identified by identifier and parameters |
|
34 | 36 | */ |
|
35 | 37 | virtual void requestDataLoading(QUuid identifier, const DataProviderParameters ¶meters) = 0; |
|
36 | 38 | |
|
37 | 39 | /** |
|
38 | 40 | * @brief requestDataAborting stop data loading of the data identified by identifier |
|
39 | 41 | */ |
|
40 | 42 | virtual void requestDataAborting(QUuid identifier) = 0; |
|
41 | 43 | |
|
42 | 44 | signals: |
|
43 | 45 | /** |
|
44 | 46 | * @brief dataProvided send dataSeries under dateTime and that corresponds of the data |
|
45 | 47 | * identified by identifier |
|
46 | 48 | */ |
|
47 | 49 | void dataProvided(QUuid identifier, std::shared_ptr<IDataSeries> dateSerie, |
|
48 | 50 | const SqpDateTime &dateTime); |
|
49 | 51 | |
|
50 | 52 | /** |
|
51 | 53 | * @brief dataProvided send dataSeries under dateTime and that corresponds of the data |
|
52 | 54 | * identified by identifier |
|
53 | 55 | */ |
|
54 | 56 | void dataProvidedProgress(QUuid identifier, double progress); |
|
55 | 57 | |
|
56 | 58 | |
|
57 | 59 | /** |
|
58 | 60 | * @brief requestConstructed send a request for the data identified by identifier |
|
59 | 61 | * @callback is the methode call by the reply of the request when it is finished. |
|
60 | 62 | */ |
|
61 | 63 | void requestConstructed(const QNetworkRequest &request, QUuid identifier, |
|
62 | 64 | std::function<void(QNetworkReply *, QUuid)> callback); |
|
63 | 65 | }; |
|
64 | 66 | |
|
65 | 67 | // Required for using shared_ptr in signals/slots |
|
66 | 68 | SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_PTR_REGISTRY, std::shared_ptr<IDataProvider>) |
|
67 | 69 | SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_FUNCTION_REGISTRY, |
|
68 | 70 | std::function<void(QNetworkReply *, QUuid)>) |
|
69 | 71 | |
|
70 | 72 | #endif // SCIQLOP_IDATAPROVIDER_H |
@@ -1,48 +1,50 | |||
|
1 | 1 | #ifndef SCIQLOP_DATASOURCEITEMACTION_H |
|
2 | 2 | #define SCIQLOP_DATASOURCEITEMACTION_H |
|
3 | 3 | |
|
4 | 4 | #include <Common/spimpl.h> |
|
5 | 5 | |
|
6 | 6 | #include <QLoggingCategory> |
|
7 | 7 | #include <QObject> |
|
8 | 8 | |
|
9 | #include <functional> | |
|
10 | ||
|
9 | 11 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceItemAction) |
|
10 | 12 | |
|
11 | 13 | class DataSourceItem; |
|
12 | 14 | |
|
13 | 15 | /** |
|
14 | 16 | * @brief The DataSourceItemAction class represents an action on a data source item. |
|
15 | 17 | * |
|
16 | 18 | * An action is a function that will be executed when the slot execute() is called. |
|
17 | 19 | */ |
|
18 | 20 | class DataSourceItemAction : public QObject { |
|
19 | 21 | |
|
20 | 22 | Q_OBJECT |
|
21 | 23 | |
|
22 | 24 | public: |
|
23 | 25 | /// Signature of the function associated to the action |
|
24 | 26 | using ExecuteFunction = std::function<void(DataSourceItem &dataSourceItem)>; |
|
25 | 27 | |
|
26 | 28 | /** |
|
27 | 29 | * Ctor |
|
28 | 30 | * @param name the name of the action |
|
29 | 31 | * @param fun the function that will be called when the action is executed |
|
30 | 32 | * @sa execute() |
|
31 | 33 | */ |
|
32 | 34 | explicit DataSourceItemAction(const QString &name, ExecuteFunction fun); |
|
33 | 35 | |
|
34 | 36 | QString name() const noexcept; |
|
35 | 37 | |
|
36 | 38 | /// Sets the data source item concerned by the action |
|
37 | 39 | void setDataSourceItem(DataSourceItem *dataSourceItem) noexcept; |
|
38 | 40 | |
|
39 | 41 | public slots: |
|
40 | 42 | /// Executes the action |
|
41 | 43 | void execute(); |
|
42 | 44 | |
|
43 | 45 | private: |
|
44 | 46 | class DataSourceItemActionPrivate; |
|
45 | 47 | spimpl::unique_impl_ptr<DataSourceItemActionPrivate> impl; |
|
46 | 48 | }; |
|
47 | 49 | |
|
48 | 50 | #endif // SCIQLOP_DATASOURCEITEMACTION_H |
General Comments 0
You need to be logged in to leave comments.
Login now