##// END OF EJS Templates
Adds method for registering a data provider in the data source controller
Alexandre Leroux -
r127:95d739a33d44
parent child
Show More
@@ -10,6 +10,7
10 10 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
11 11
12 12 class DataSourceItem;
13 class IDataProvider;
13 14
14 15 /**
15 16 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
@@ -42,6 +43,17 public:
42 43 void setDataSourceItem(const QUuid &dataSourceUid,
43 44 std::unique_ptr<DataSourceItem> dataSourceItem) noexcept;
44 45
46 /**
47 * Sets the data provider used to retrieve data from of a data source. The controller takes
48 * ownership of the provider.
49 * @param dataSourceUid the unique id with which the data source has been registered into the
50 * controller. If it is invalid, the method has no effect.
51 * @param dataProvider the provider of the data source
52 * @sa registerDataSource()
53 */
54 void setDataProvider(const QUuid &dataSourceUid,
55 std::unique_ptr<IDataProvider> dataProvider) noexcept;
56
45 57 public slots:
46 58 /// Manage init/end of the controller
47 59 void initialize();
@@ -1,6 +1,8
1 1 #include <DataSource/DataSourceController.h>
2 2 #include <DataSource/DataSourceItem.h>
3 3
4 #include <Data/IDataProvider.h>
5
4 6 #include <QMutex>
5 7 #include <QThread>
6 8
@@ -16,6 +18,8 public:
16 18 QHash<QUuid, QString> m_DataSources;
17 19 /// Data sources structures
18 20 std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
21 /// Data providers registered
22 std::map<QUuid, std::unique_ptr<IDataProvider> > m_DataProviders;
19 23 };
20 24
21 25 DataSourceController::DataSourceController(QObject *parent)
@@ -59,6 +63,19 void DataSourceController::setDataSourceItem(
59 63 }
60 64 }
61 65
66 void DataSourceController::setDataProvider(const QUuid &dataSourceUid,
67 std::unique_ptr<IDataProvider> dataProvider) noexcept
68 {
69 if (impl->m_DataSources.contains(dataSourceUid)) {
70 impl->m_DataProviders.insert(std::make_pair(dataSourceUid, std::move(dataProvider)));
71 }
72 else {
73 qCWarning(LOG_DataSourceController()) << tr("Can't set data provider for uid %1 : no data "
74 "source has been registered with the uid")
75 .arg(dataSourceUid.toString());
76 }
77 }
78
62 79 void DataSourceController::initialize()
63 80 {
64 81 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init")
General Comments 0
You need to be logged in to leave comments. Login now