@@ -1,35 +1,44 | |||
|
1 | 1 | #ifndef SCIQLOP_VARIABLE_H |
|
2 | 2 | #define SCIQLOP_VARIABLE_H |
|
3 | 3 | |
|
4 |
#include < |
|
|
4 | #include <Data/SqpDateTime.h> | |
|
5 | ||
|
5 | 6 | |
|
7 | #include <QLoggingCategory> | |
|
6 | 8 | #include <QObject> |
|
7 | 9 | |
|
10 | #include <Common/spimpl.h> | |
|
11 | ||
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_Variable) | |
|
13 | ||
|
8 | 14 | class IDataSeries; |
|
9 | 15 | class QString; |
|
10 | 16 | |
|
11 | 17 | /** |
|
12 | 18 | * @brief The Variable class represents a variable in SciQlop. |
|
13 | 19 | */ |
|
14 | 20 | class Variable { |
|
15 | 21 | public: |
|
16 | 22 | explicit Variable(const QString &name, const QString &unit, const QString &mission); |
|
17 | 23 | |
|
18 | 24 | QString name() const noexcept; |
|
19 | 25 | QString mission() const noexcept; |
|
20 | 26 | QString unit() const noexcept; |
|
21 | 27 | |
|
22 | 28 | void addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept; |
|
23 | 29 | |
|
24 | 30 | /// @return the data of the variable, nullptr if there is no data |
|
25 | 31 | IDataSeries *dataSeries() const noexcept; |
|
26 | 32 | |
|
33 | public slots: | |
|
34 | void onXRangeChanged(SqpDateTime dateTime); | |
|
35 | ||
|
27 | 36 | private: |
|
28 | 37 | class VariablePrivate; |
|
29 | 38 | spimpl::unique_impl_ptr<VariablePrivate> impl; |
|
30 | 39 | }; |
|
31 | 40 | |
|
32 | 41 | // Required for using shared_ptr in signals/slots |
|
33 | 42 | Q_DECLARE_METATYPE(std::shared_ptr<Variable>) |
|
34 | 43 | |
|
35 | 44 | #endif // SCIQLOP_VARIABLE_H |
@@ -1,48 +1,58 | |||
|
1 | 1 | #include "Variable/Variable.h" |
|
2 | 2 | |
|
3 | 3 | #include <Data/IDataSeries.h> |
|
4 | #include <Data/SqpDateTime.h> | |
|
5 | ||
|
6 | Q_LOGGING_CATEGORY(LOG_Variable, "Variable") | |
|
4 | 7 | |
|
5 | 8 | struct Variable::VariablePrivate { |
|
6 | 9 | explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission) |
|
7 | 10 | : m_Name{name}, m_Unit{unit}, m_Mission{mission}, m_DataSeries{nullptr} |
|
8 | 11 | { |
|
9 | 12 | } |
|
10 | 13 | |
|
11 | 14 | QString m_Name; |
|
12 | 15 | QString m_Unit; |
|
13 | 16 | QString m_Mission; |
|
17 | ||
|
18 | SqpDateTime m_DateTime; // The dateTime available in the view and loaded. not the cache. | |
|
14 | 19 | std::unique_ptr<IDataSeries> m_DataSeries; |
|
15 | 20 | }; |
|
16 | 21 | |
|
17 | 22 | Variable::Variable(const QString &name, const QString &unit, const QString &mission) |
|
18 | 23 | : impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, mission)} |
|
19 | 24 | { |
|
20 | 25 | } |
|
21 | 26 | |
|
22 | 27 | QString Variable::name() const noexcept |
|
23 | 28 | { |
|
24 | 29 | return impl->m_Name; |
|
25 | 30 | } |
|
26 | 31 | |
|
27 | 32 | QString Variable::mission() const noexcept |
|
28 | 33 | { |
|
29 | 34 | return impl->m_Mission; |
|
30 | 35 | } |
|
31 | 36 | |
|
32 | 37 | QString Variable::unit() const noexcept |
|
33 | 38 | { |
|
34 | 39 | return impl->m_Unit; |
|
35 | 40 | } |
|
36 | 41 | |
|
37 | 42 | void Variable::addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept |
|
38 | 43 | { |
|
39 | 44 | if (!impl->m_DataSeries) { |
|
40 | 45 | impl->m_DataSeries = std::move(dataSeries); |
|
41 | 46 | } |
|
42 | 47 | /// @todo : else, merge the two data series (if possible) |
|
43 | 48 | } |
|
44 | 49 | |
|
45 | 50 | IDataSeries *Variable::dataSeries() const noexcept |
|
46 | 51 | { |
|
47 | 52 | return impl->m_DataSeries.get(); |
|
48 | 53 | } |
|
54 | ||
|
55 | void Variable::onXRangeChanged(SqpDateTime dateTime) | |
|
56 | { | |
|
57 | qCInfo(LOG_Variable()) << "onXRangeChanged detected"; | |
|
58 | } |
General Comments 0
You need to be logged in to leave comments.
Login now