##// END OF EJS Templates
Creates a default provider that will be returned by the mock plugin
Alexandre Leroux -
r128:59f921efd8e4
parent child
Show More
@@ -0,0 +1,16
1 #ifndef SCIQLOP_COSINUSPROVIDER_H
2 #define SCIQLOP_COSINUSPROVIDER_H
3
4 #include <Data/IDataProvider.h>
5
6 /**
7 * @brief The CosinusProvider class is an example of how a data provider can generate data
8 */
9 class CosinusProvider : public IDataProvider {
10 public:
11 /// @sa IDataProvider::retrieveData()
12 std::unique_ptr<IDataSeries>
13 retrieveData(const DataProviderParameters &parameters) const override;
14 };
15
16 #endif // SCIQLOP_COSINUSPROVIDER_H
@@ -0,0 +1,28
1 #include "CosinusProvider.h"
2
3 #include <Data/DataProviderParameters.h>
4 #include <Data/ScalarSeries.h>
5
6 std::unique_ptr<IDataSeries>
7 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
8 {
9 // Gets the timerange from the parameters
10 auto start = parameters.m_TStart;
11 auto end = parameters.m_TEnd;
12
13 // We assure that timerange is valid
14 if (end < start) {
15 std::swap(start, end);
16 }
17
18 // Generates scalar series containing cosinus values (one value per second)
19 auto scalarSeries
20 = std::make_unique<ScalarSeries>(end - start, QStringLiteral("t"), QStringLiteral(""));
21
22 for (auto time = start; time < end; ++time) {
23 auto dataIndex = time - start;
24 scalarSeries->setData(dataIndex, time, std::cos(time));
25 }
26
27 return scalarSeries;
28 }
General Comments 0
You need to be logged in to leave comments. Login now