##// END OF EJS Templates
Add impletation for displaying data that are already in cache when...
Add impletation for displaying data that are already in cache when acquisition is requested

File last commit:

r531:41183664294f
r573:575eda7156d0
Show More
VariableCacheStrategy.cpp
52 lines | 1.6 KiB | text/x-c | CppLexer
/ core / src / Variable / VariableCacheStrategy.cpp
Implementation of the VariableCacheStrategy
r531 #include "Variable/VariableCacheStrategy.h"
#include "Settings/SqpSettingsDefs.h"
#include "Variable/Variable.h"
#include "Variable/VariableController.h"
Q_LOGGING_CATEGORY(LOG_VariableCacheStrategy, "VariableCacheStrategy")
struct VariableCacheStrategy::VariableCacheStrategyPrivate {
VariableCacheStrategyPrivate() : m_CacheStrategy{CacheStrategy::FixedTolerance} {}
CacheStrategy m_CacheStrategy;
};
VariableCacheStrategy::VariableCacheStrategy(QObject *parent)
: QObject{parent}, impl{spimpl::make_unique_impl<VariableCacheStrategyPrivate>()}
{
}
std::pair<SqpRange, SqpRange>
VariableCacheStrategy::computeCacheRange(const SqpRange &vRange, const SqpRange &rangeRequested)
{
auto varRanges = std::pair<SqpRange, SqpRange>{};
auto toleranceFactor = SqpSettings::toleranceValue(GENERAL_TOLERANCE_AT_UPDATE_KEY,
GENERAL_TOLERANCE_AT_UPDATE_DEFAULT_VALUE);
auto tolerance = toleranceFactor * (rangeRequested.m_TEnd - rangeRequested.m_TStart);
switch (impl->m_CacheStrategy) {
case CacheStrategy::FixedTolerance: {
varRanges.first = rangeRequested;
varRanges.second
= SqpRange{rangeRequested.m_TStart - tolerance, rangeRequested.m_TEnd + tolerance};
break;
}
case CacheStrategy::TwoThreashold: {
// TODO Implement
break;
}
default:
qCCritical(LOG_VariableCacheStrategy())
<< tr("Impossible to use compute the cache range with an unknow cache strategy");
// No action
break;
}
return varRanges;
}