##// END OF EJS Templates
Merge branch 'feature/DataSeriesIterator' into develop
Merge branch 'feature/DataSeriesIterator' into develop

File last commit:

r554:5d1bac48fb3a
r559:575b804cd7dd merge
Show More
Variable.cpp
211 lines | 5.5 KiB | text/x-c | CppLexer
Alexandre Leroux
Changes Variable from struct to class
r163 #include "Variable/Variable.h"
Alexandre Leroux
Adds data series to a variable
r164 #include <Data/IDataSeries.h>
Change SqpRange for SqpDateTime
r512 #include <Data/SqpRange.h>
Variable slot is called when x range of its graph changed
r226
Add thread protection on variable
r541 #include <QMutex>
Add current progression for thread fix
r364 #include <QReadWriteLock>
#include <QThread>
Variable slot is called when x range of its graph changed
r226 Q_LOGGING_CATEGORY(LOG_Variable, "Variable")
Alexandre Leroux
Adds data series to a variable
r164
Alexandre Leroux
Changes Variable from struct to class
r163 struct Variable::VariablePrivate {
Change SqpRange for SqpDateTime
r512 explicit VariablePrivate(const QString &name, const SqpRange &dateTime,
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r406 const QVariantHash &metadata)
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 : m_Name{name}, m_Range{dateTime}, m_Metadata{metadata}, m_DataSeries{nullptr}
Alexandre Leroux
Changes Variable from struct to class
r163 {
}
Add thread protection on variable
r541 void lockRead() { m_Lock.lockForRead(); }
void lockWrite() { m_Lock.lockForWrite(); }
void unlock() { m_Lock.unlock(); }
Alexandre Leroux
Changes Variable from struct to class
r163 QString m_Name;
Variable slot is called when x range of its graph changed
r226
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 SqpRange m_Range;
SqpRange m_CacheRange;
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r406 QVariantHash m_Metadata;
The dataSeries of a variable is now shared istead of uniq to avoid...
r542 std::shared_ptr<IDataSeries> m_DataSeries;
Add thread protection on variable
r541
QReadWriteLock m_Lock;
Alexandre Leroux
Changes Variable from struct to class
r163 };
Change SqpRange for SqpDateTime
r512 Variable::Variable(const QString &name, const SqpRange &dateTime, const QVariantHash &metadata)
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r406 : impl{spimpl::make_unique_impl<VariablePrivate>(name, dateTime, metadata)}
Alexandre Leroux
Changes Variable from struct to class
r163 {
}
QString Variable::name() const noexcept
{
Add thread protection on variable
r541 impl->lockRead();
auto name = impl->m_Name;
impl->unlock();
return name;
Alexandre Leroux
Changes Variable from struct to class
r163 }
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 SqpRange Variable::range() const noexcept
The mock plugin can now create data with view operation
r235 {
Add thread protection on variable
r541 impl->lockRead();
auto range = impl->m_Range;
impl->unlock();
return range;
The mock plugin can now create data with view operation
r235 }
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 void Variable::setRange(const SqpRange &range) noexcept
Implementation of the new Dela T computation strategy
r260 {
Add thread protection on variable
r541 impl->lockWrite();
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 impl->m_Range = range;
Add thread protection on variable
r541 impl->unlock();
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 }
SqpRange Variable::cacheRange() const noexcept
{
Add thread protection on variable
r541 impl->lockRead();
auto cacheRange = impl->m_CacheRange;
impl->unlock();
return cacheRange;
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 }
void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
{
Add thread protection on variable
r541 impl->lockWrite();
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 impl->m_CacheRange = cacheRange;
Add thread protection on variable
r541 impl->unlock();
Implementation of the new Dela T computation strategy
r260 }
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 void Variable::setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
Alexandre Leroux
Adds data series to a variable
r164 {
The dataSeries of a variable is now shared istead of uniq to avoid...
r542 qCDebug(LOG_Variable()) << "TORM Variable::setDataSeries"
<< QThread::currentThread()->objectName();
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 if (!dataSeries) {
/// @todo ALX : log
return;
Alexandre Leroux
Adds data series to a variable
r164 }
Add thread protection on variable
r541 impl->lockWrite();
Update Variable impl for v5
r538 impl->m_DataSeries = dataSeries->clone();
Add thread protection on variable
r541 impl->unlock();
Update Variable impl for v5
r538 }
void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
{
The dataSeries of a variable is now shared istead of uniq to avoid...
r542 qCDebug(LOG_Variable()) << "TORM Variable::mergeDataSeries"
Add thread protection on variable
r541 << QThread::currentThread()->objectName();
Update Variable impl for v5
r538 if (!dataSeries) {
/// @todo ALX : log
return;
}
// Add or merge the data
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 // Inits the data series of the variable
Add thread protection on variable
r541 impl->lockWrite();
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 if (!impl->m_DataSeries) {
impl->m_DataSeries = dataSeries->clone();
}
else {
The mock plugin can now create data with view operation
r235 impl->m_DataSeries->merge(dataSeries.get());
}
Add thread protection on variable
r541 impl->unlock();
Update Variable impl for v5
r538
// sub the data
Alexandre Leroux
Renames subData() to subDataSeries()...
r554 auto subData = this->dataSeries()->subDataSeries(this->cacheRange());
The dataSeries of a variable is now shared istead of uniq to avoid...
r542 qCDebug(LOG_Variable()) << "TORM: Variable::mergeDataSeries sub" << subData->range();
Update Variable impl for v5
r538 this->setDataSeries(subData);
The dataSeries of a variable is now shared istead of uniq to avoid...
r542 qCDebug(LOG_Variable()) << "TORM: Variable::mergeDataSeries set" << this->dataSeries()->range();
Alexandre Leroux
Adds data series to a variable
r164 }
Alexandre Leroux
Handles creations for scalar series
r182
The dataSeries of a variable is now shared istead of uniq to avoid...
r542 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
Alexandre Leroux
Handles creations for scalar series
r182 {
Add thread protection on variable
r541 impl->lockRead();
The dataSeries of a variable is now shared istead of uniq to avoid...
r542 auto dataSeries = impl->m_DataSeries;
Add thread protection on variable
r541 impl->unlock();
return dataSeries;
Alexandre Leroux
Handles creations for scalar series
r182 }
Variable slot is called when x range of its graph changed
r226
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r406 QVariantHash Variable::metadata() const noexcept
{
Add thread protection on variable
r541 impl->lockRead();
auto metadata = impl->m_Metadata;
impl->unlock();
return metadata;
Alexandre Leroux
Adds QVariantHash to store metadata in a variable
r406 }
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 bool Variable::contains(const SqpRange &range) const noexcept
Variable slot is called when x range of its graph changed
r226 {
Add thread protection on variable
r541 impl->lockRead();
auto res = impl->m_Range.contains(range);
impl->unlock();
return res;
Variable slot is called when x range of its graph changed
r226 }
Add intersect méthode on variable and sqpDateTime...
r258
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 bool Variable::intersect(const SqpRange &range) const noexcept
Add intersect méthode on variable and sqpDateTime...
r258 {
Add thread protection on variable
r541
impl->lockRead();
auto res = impl->m_Range.intersect(range);
impl->unlock();
return res;
Add intersect méthode on variable and sqpDateTime...
r258 }
The cache is now updated only if date requested has been successfully...
r318
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 bool Variable::isInside(const SqpRange &range) const noexcept
The cache is now updated only if date requested has been successfully...
r318 {
Add thread protection on variable
r541 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
r532 }
bool Variable::cacheContains(const SqpRange &range) const noexcept
{
Add thread protection on variable
r541 impl->lockRead();
auto res = impl->m_CacheRange.contains(range);
impl->unlock();
return res;
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 }
bool Variable::cacheIntersect(const SqpRange &range) const noexcept
{
Add thread protection on variable
r541 impl->lockRead();
auto res = impl->m_CacheRange.intersect(range);
impl->unlock();
return res;
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 }
bool Variable::cacheIsInside(const SqpRange &range) const noexcept
{
Add thread protection on variable
r541 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
r532 }
Add thread protection on variable
r541 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) const noexcept
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 {
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
r538 << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd};
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 }
else if (range.m_TStart < impl->m_CacheRange.m_TEnd) {
Update Variable impl for v5
r538 notInCache << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd};
add CacheRange for Variable and the provideNotInCacheRangeList method
r532 }
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...
r318 }