Variable.cpp
87 lines
| 2.0 KiB
| text/x-c
|
CppLexer
Alexandre Leroux
|
r151 | #include "Variable/Variable.h" | ||
Alexandre Leroux
|
r152 | #include <Data/IDataSeries.h> | ||
r210 | #include <Data/SqpDateTime.h> | |||
Q_LOGGING_CATEGORY(LOG_Variable, "Variable") | ||||
Alexandre Leroux
|
r152 | |||
Alexandre Leroux
|
r151 | struct Variable::VariablePrivate { | ||
r212 | 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
|
r151 | { | ||
} | ||||
QString m_Name; | ||||
QString m_Unit; | ||||
QString m_Mission; | ||||
r210 | ||||
SqpDateTime m_DateTime; // The dateTime available in the view and loaded. not the cache. | ||||
Alexandre Leroux
|
r152 | std::unique_ptr<IDataSeries> m_DataSeries; | ||
Alexandre Leroux
|
r151 | }; | ||
r212 | 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
|
r151 | { | ||
} | ||||
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
|
r152 | |||
r219 | SqpDateTime Variable::dateTime() const noexcept | |||
{ | ||||
return impl->m_DateTime; | ||||
} | ||||
r241 | void Variable::setDateTime(const SqpDateTime &dateTime) noexcept | |||
{ | ||||
impl->m_DateTime = dateTime; | ||||
} | ||||
r219 | void Variable::setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept | |||
Alexandre Leroux
|
r152 | { | ||
if (!impl->m_DataSeries) { | ||||
impl->m_DataSeries = std::move(dataSeries); | ||||
} | ||||
r219 | } | |||
void Variable::onAddDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept | ||||
{ | ||||
if (impl->m_DataSeries) { | ||||
impl->m_DataSeries->merge(dataSeries.get()); | ||||
r276 | emit updated(); | |||
r219 | } | |||
Alexandre Leroux
|
r152 | } | ||
Alexandre Leroux
|
r169 | |||
IDataSeries *Variable::dataSeries() const noexcept | ||||
{ | ||||
return impl->m_DataSeries.get(); | ||||
} | ||||
r210 | ||||
r227 | bool Variable::contains(const SqpDateTime &dateTime) | |||
r210 | { | |||
r241 | return impl->m_DateTime.contains(dateTime); | |||
r210 | } | |||
r240 | ||||
bool Variable::intersect(const SqpDateTime &dateTime) | ||||
{ | ||||
return impl->m_DateTime.intersect(dateTime); | ||||
} | ||||