Variable.cpp
94 lines
| 2.3 KiB
| text/x-c
|
CppLexer
Alexandre Leroux
|
r163 | #include "Variable/Variable.h" | ||
Alexandre Leroux
|
r164 | #include <Data/IDataSeries.h> | ||
r226 | #include <Data/SqpDateTime.h> | |||
Q_LOGGING_CATEGORY(LOG_Variable, "Variable") | ||||
Alexandre Leroux
|
r164 | |||
Alexandre Leroux
|
r163 | struct Variable::VariablePrivate { | ||
r228 | explicit VariablePrivate(const QString &name, const QString &unit, const QString &mission, | |||
const SqpDateTime &dateTime) | ||||
: m_Name{name}, | ||||
m_Unit{unit}, | ||||
m_Mission{mission}, | ||||
m_DateTime{dateTime}, | ||||
m_DataSeries{nullptr} | ||||
Alexandre Leroux
|
r163 | { | ||
} | ||||
QString m_Name; | ||||
QString m_Unit; | ||||
QString m_Mission; | ||||
r226 | ||||
SqpDateTime m_DateTime; // The dateTime available in the view and loaded. not the cache. | ||||
Alexandre Leroux
|
r164 | std::unique_ptr<IDataSeries> m_DataSeries; | ||
Alexandre Leroux
|
r163 | }; | ||
r228 | Variable::Variable(const QString &name, const QString &unit, const QString &mission, | |||
const SqpDateTime &dateTime) | ||||
: impl{spimpl::make_unique_impl<VariablePrivate>(name, unit, mission, dateTime)} | ||||
Alexandre Leroux
|
r163 | { | ||
} | ||||
QString Variable::name() const noexcept | ||||
{ | ||||
return impl->m_Name; | ||||
} | ||||
QString Variable::mission() const noexcept | ||||
{ | ||||
return impl->m_Mission; | ||||
} | ||||
QString Variable::unit() const noexcept | ||||
{ | ||||
return impl->m_Unit; | ||||
} | ||||
Alexandre Leroux
|
r164 | |||
r235 | SqpDateTime Variable::dateTime() const noexcept | |||
{ | ||||
return impl->m_DateTime; | ||||
} | ||||
void Variable::setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept | ||||
Alexandre Leroux
|
r164 | { | ||
if (!impl->m_DataSeries) { | ||||
impl->m_DataSeries = std::move(dataSeries); | ||||
} | ||||
r235 | } | |||
void Variable::onAddDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept | ||||
{ | ||||
if (impl->m_DataSeries) { | ||||
impl->m_DataSeries->merge(dataSeries.get()); | ||||
emit dataCacheUpdated(); | ||||
} | ||||
Alexandre Leroux
|
r164 | } | ||
Alexandre Leroux
|
r182 | |||
IDataSeries *Variable::dataSeries() const noexcept | ||||
{ | ||||
return impl->m_DataSeries.get(); | ||||
} | ||||
r226 | ||||
r243 | bool Variable::contains(const SqpDateTime &dateTime) | |||
r226 | { | |||
r228 | if (!impl->m_DateTime.contains(dateTime)) { | |||
// The current variable dateTime isn't enough to display the dateTime requested. | ||||
// We have to update it to the new dateTime requested. | ||||
// the correspondant new data to display will be given by the cache if possible and the | ||||
// provider if necessary. | ||||
qCInfo(LOG_Variable()) << "NEW DATE NEEDED"; | ||||
r253 | // impl->m_DateTime = dateTime; | |||
r235 | ||||
return false; | ||||
r228 | } | |||
r235 | ||||
return true; | ||||
r226 | } | |||
r253 | ||||
bool Variable::intersect(const SqpDateTime &dateTime) | ||||
{ | ||||
return impl->m_DateTime.intersect(dateTime); | ||||
} | ||||