##// END OF EJS Templates
Fix bug when creating two variables crash the app. ...
Fix bug when creating two variables crash the app. Variable as now invalid range and cache range at creation

File last commit:

r581:5ee6983593ec
r699:a7f60f6512e6
Show More
VariableCacheStrategy.cpp
52 lines | 1.6 KiB | text/x-c | CppLexer
/ core / src / Variable / VariableCacheStrategy.cpp
Implementation of the VariableCacheStrategy
r502 #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>
Change strategy method name
r581 VariableCacheStrategy::computeStrategyRanges(const SqpRange &vRange, const SqpRange &rangeRequested)
Implementation of the VariableCacheStrategy
r502 {
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;
}