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