##// END OF EJS Templates
Update networkcontroller for abort mechanism
Update networkcontroller for abort mechanism

File last commit:

r661:a1a7563eadb0
r698:076c09acb9f6
Show More
Variable.cpp
307 lines | 8.2 KiB | text/x-c | CppLexer
Alexandre Leroux
Changes Variable from struct to class
r151 #include "Variable/Variable.h"
Alexandre Leroux
Adds data series to a variable
r152 #include <Data/IDataSeries.h>
Change SqpRange for SqpDateTime
r471 #include <Data/SqpRange.h>
Variable slot is called when x range of its graph changed
r210
Add thread protection on variable
r512 #include <QMutex>
Add current progression for thread fix
r336 #include <QReadWriteLock>
#include <QThread>
Variable slot is called when x range of its graph changed
r210 Q_LOGGING_CATEGORY(LOG_Variable, "Variable")
Alexandre Leroux
Adds data series to a variable
r152
Alexandre Leroux
Changes Variable from struct to class
r151 struct Variable::VariablePrivate {
Change SqpRange for SqpDateTime
r471 explicit VariablePrivate(const QString &name, const SqpRange &dateTime,
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r373 const QVariantHash &metadata)
Alexandre Leroux
Fixed untimely update of the range to be displayed in the variable widget
r611 : m_Name{name},
m_Range{dateTime},
m_Metadata{metadata},
m_DataSeries{nullptr},
Alexandre Leroux
Creates attribute to get nb points of a variable
r659 m_RealRange{INVALID_RANGE},
m_NbPoints{0}
Alexandre Leroux
Changes Variable from struct to class
r151 {
}
Alexandre Leroux
Clones variable
r651 VariablePrivate(const VariablePrivate &other)
: m_Name{other.m_Name},
m_Range{other.m_Range},
m_Metadata{other.m_Metadata},
m_DataSeries{other.m_DataSeries != nullptr ? other.m_DataSeries->clone() : nullptr},
Alexandre Leroux
Creates attribute to get nb points of a variable
r659 m_RealRange{other.m_RealRange},
m_NbPoints{other.m_NbPoints}
Alexandre Leroux
Clones variable
r651 {
}
Add thread protection on variable
r512 void lockRead() { m_Lock.lockForRead(); }
void lockWrite() { m_Lock.lockForWrite(); }
void unlock() { m_Lock.unlock(); }
Alexandre Leroux
Calls purge() method when setting cache range or data series of a variable
r630 void purgeDataSeries()
{
if (m_DataSeries) {
m_DataSeries->purge(m_CacheRange.m_TStart, m_CacheRange.m_TEnd);
}
updateRealRange();
Alexandre Leroux
Updates variable attribute when data series is changing
r661 updateNbPoints();
Alexandre Leroux
Calls purge() method when setting cache range or data series of a variable
r630 }
Alexandre Leroux
Updates variable attribute when data series is changing
r661 void updateNbPoints() { m_NbPoints = m_DataSeries ? m_DataSeries->nbPoints() : 0; }
Alexandre Leroux
Fixed untimely update of the range to be displayed in the variable widget
r611 /// Updates real range according to current variable range and data series
void updateRealRange()
{
if (m_DataSeries) {
m_DataSeries->lockRead();
auto end = m_DataSeries->cend();
auto minXAxisIt = m_DataSeries->minXAxisData(m_Range.m_TStart);
auto maxXAxisIt = m_DataSeries->maxXAxisData(m_Range.m_TEnd);
m_RealRange = (minXAxisIt != end && maxXAxisIt != end)
? SqpRange{minXAxisIt->x(), maxXAxisIt->x()}
: INVALID_RANGE;
m_DataSeries->unlock();
}
else {
m_RealRange = INVALID_RANGE;
}
}
Alexandre Leroux
Changes Variable from struct to class
r151 QString m_Name;
Variable slot is called when x range of its graph changed
r210
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 SqpRange m_Range;
SqpRange m_CacheRange;
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r373 QVariantHash m_Metadata;
The dataSeries of a variable is now shared istead of uniq to avoid...
r513 std::shared_ptr<IDataSeries> m_DataSeries;
Alexandre Leroux
Fixed untimely update of the range to be displayed in the variable widget
r611 SqpRange m_RealRange;
Alexandre Leroux
Creates attribute to get nb points of a variable
r659 int m_NbPoints;
Add thread protection on variable
r512
QReadWriteLock m_Lock;
Alexandre Leroux
Changes Variable from struct to class
r151 };
Change SqpRange for SqpDateTime
r471 Variable::Variable(const QString &name, const SqpRange &dateTime, const QVariantHash &metadata)
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r373 : impl{spimpl::make_unique_impl<VariablePrivate>(name, dateTime, metadata)}
Alexandre Leroux
Changes Variable from struct to class
r151 {
}
Alexandre Leroux
Clones variable
r651 Variable::Variable(const Variable &other)
: impl{spimpl::make_unique_impl<VariablePrivate>(*other.impl)}
{
}
std::shared_ptr<Variable> Variable::clone() const
{
return std::make_shared<Variable>(*this);
}
Alexandre Leroux
Changes Variable from struct to class
r151 QString Variable::name() const noexcept
{
Add thread protection on variable
r512 impl->lockRead();
auto name = impl->m_Name;
impl->unlock();
return name;
Alexandre Leroux
Changes Variable from struct to class
r151 }
Alexandre Leroux
Sets variable name
r638 void Variable::setName(const QString &name) noexcept
{
impl->lockWrite();
impl->m_Name = name;
impl->unlock();
}
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 SqpRange Variable::range() const noexcept
The mock plugin can now create data with view operation
r219 {
Add thread protection on variable
r512 impl->lockRead();
auto range = impl->m_Range;
impl->unlock();
return range;
The mock plugin can now create data with view operation
r219 }
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 void Variable::setRange(const SqpRange &range) noexcept
Implementation of the new Dela T computation strategy
r241 {
Add thread protection on variable
r512 impl->lockWrite();
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 impl->m_Range = range;
Alexandre Leroux
Fixed untimely update of the range to be displayed in the variable widget
r611 impl->updateRealRange();
Add thread protection on variable
r512 impl->unlock();
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 }
SqpRange Variable::cacheRange() const noexcept
{
Add thread protection on variable
r512 impl->lockRead();
auto cacheRange = impl->m_CacheRange;
impl->unlock();
return cacheRange;
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 }
void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
{
Add thread protection on variable
r512 impl->lockWrite();
Alexandre Leroux
Calls purge() method when setting cache range or data series of a variable
r630 if (cacheRange != impl->m_CacheRange) {
impl->m_CacheRange = cacheRange;
impl->purgeDataSeries();
}
Add thread protection on variable
r512 impl->unlock();
Implementation of the new Dela T computation strategy
r241 }
Alexandre Leroux
Creates attribute to get nb points of a variable
r659 int Variable::nbPoints() const noexcept
{
return impl->m_NbPoints;
}
Alexandre Leroux
Fixed untimely update of the range to be displayed in the variable widget
r611 SqpRange Variable::realRange() const noexcept
{
return impl->m_RealRange;
}
Update Variable impl for v5
r509 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
{
The dataSeries of a variable is now shared istead of uniq to avoid...
r513 qCDebug(LOG_Variable()) << "TORM Variable::mergeDataSeries"
Add thread protection on variable
r512 << QThread::currentThread()->objectName();
Update Variable impl for v5
r509 if (!dataSeries) {
/// @todo ALX : log
return;
}
// Add or merge the data
Add thread protection on variable
r512 impl->lockWrite();
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r287 if (!impl->m_DataSeries) {
impl->m_DataSeries = dataSeries->clone();
}
else {
The mock plugin can now create data with view operation
r219 impl->m_DataSeries->merge(dataSeries.get());
}
Alexandre Leroux
Calls purge() method when setting cache range or data series of a variable
r630 impl->purgeDataSeries();
Add thread protection on variable
r512 impl->unlock();
Alexandre Leroux
Adds data series to a variable
r152 }
Alexandre Leroux
Handles creations for scalar series
r169
The dataSeries of a variable is now shared istead of uniq to avoid...
r513 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
Alexandre Leroux
Handles creations for scalar series
r169 {
Add thread protection on variable
r512 impl->lockRead();
The dataSeries of a variable is now shared istead of uniq to avoid...
r513 auto dataSeries = impl->m_DataSeries;
Add thread protection on variable
r512 impl->unlock();
return dataSeries;
Alexandre Leroux
Handles creations for scalar series
r169 }
Variable slot is called when x range of its graph changed
r210
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r373 QVariantHash Variable::metadata() const noexcept
{
Add thread protection on variable
r512 impl->lockRead();
auto metadata = impl->m_Metadata;
impl->unlock();
return metadata;
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r373 }
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 bool Variable::contains(const SqpRange &range) const noexcept
Variable slot is called when x range of its graph changed
r210 {
Add thread protection on variable
r512 impl->lockRead();
auto res = impl->m_Range.contains(range);
impl->unlock();
return res;
Variable slot is called when x range of its graph changed
r210 }
Add intersect méthode on variable and sqpDateTime...
r240
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 bool Variable::intersect(const SqpRange &range) const noexcept
Add intersect méthode on variable and sqpDateTime...
r240 {
Add thread protection on variable
r512
impl->lockRead();
auto res = impl->m_Range.intersect(range);
impl->unlock();
return res;
Add intersect méthode on variable and sqpDateTime...
r240 }
The cache is now updated only if date requested has been successfully...
r293
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 bool Variable::isInside(const SqpRange &range) const noexcept
The cache is now updated only if date requested has been successfully...
r293 {
Add thread protection on variable
r512 impl->lockRead();
auto res = range.contains(SqpRange{impl->m_Range.m_TStart, impl->m_Range.m_TEnd});
impl->unlock();
return res;
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 }
bool Variable::cacheContains(const SqpRange &range) const noexcept
{
Add thread protection on variable
r512 impl->lockRead();
auto res = impl->m_CacheRange.contains(range);
impl->unlock();
return res;
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 }
bool Variable::cacheIntersect(const SqpRange &range) const noexcept
{
Add thread protection on variable
r512 impl->lockRead();
auto res = impl->m_CacheRange.intersect(range);
impl->unlock();
return res;
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 }
bool Variable::cacheIsInside(const SqpRange &range) const noexcept
{
Add thread protection on variable
r512 impl->lockRead();
auto res = range.contains(SqpRange{impl->m_CacheRange.m_TStart, impl->m_CacheRange.m_TEnd});
impl->unlock();
return res;
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 }
Add thread protection on variable
r512 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) const noexcept
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 {
Add method to get range in cacheRange
r537 // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 auto notInCache = QVector<SqpRange>{};
if (!this->cacheContains(range)) {
if (range.m_TEnd <= impl->m_CacheRange.m_TStart
|| range.m_TStart >= impl->m_CacheRange.m_TEnd) {
notInCache << range;
}
else if (range.m_TStart < impl->m_CacheRange.m_TStart
&& range.m_TEnd <= impl->m_CacheRange.m_TEnd) {
notInCache << SqpRange{range.m_TStart, impl->m_CacheRange.m_TStart};
}
else if (range.m_TStart < impl->m_CacheRange.m_TStart
&& range.m_TEnd > impl->m_CacheRange.m_TEnd) {
notInCache << SqpRange{range.m_TStart, impl->m_CacheRange.m_TStart}
Update Variable impl for v5
r509 << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd};
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 }
else if (range.m_TStart < impl->m_CacheRange.m_TEnd) {
Update Variable impl for v5
r509 notInCache << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd};
add CacheRange for Variable and the provideNotInCacheRangeList method
r503 }
else {
qCCritical(LOG_Variable()) << tr("Detection of unknown case.")
<< QThread::currentThread();
}
}
return notInCache;
The cache is now updated only if date requested has been successfully...
r293 }
Add method to get range in cacheRange
r537
QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const noexcept
{
// This code assume that cach in contigue. Can return 0 or 1 SqpRange
auto inCache = QVector<SqpRange>{};
Add test for cach providing methods of variable
r552 if (this->intersect(range)) {
if (range.m_TStart <= impl->m_CacheRange.m_TStart
&& range.m_TEnd >= impl->m_CacheRange.m_TStart
&& range.m_TEnd < impl->m_CacheRange.m_TEnd) {
inCache << SqpRange{impl->m_CacheRange.m_TStart, range.m_TEnd};
Add method to get range in cacheRange
r537 }
else if (range.m_TStart >= impl->m_CacheRange.m_TStart
Add test for cach providing methods of variable
r552 && range.m_TEnd <= impl->m_CacheRange.m_TEnd) {
Add method to get range in cacheRange
r537 inCache << range;
}
Add test for cach providing methods of variable
r552 else if (range.m_TStart > impl->m_CacheRange.m_TStart
&& range.m_TEnd > impl->m_CacheRange.m_TEnd) {
inCache << SqpRange{range.m_TStart, impl->m_CacheRange.m_TEnd};
}
else if (range.m_TStart <= impl->m_CacheRange.m_TStart
&& range.m_TEnd >= impl->m_CacheRange.m_TEnd) {
inCache << impl->m_CacheRange;
Add method to get range in cacheRange
r537 }
else {
qCCritical(LOG_Variable()) << tr("Detection of unknown case.")
<< QThread::currentThread();
}
}
return inCache;
}