##// END OF EJS Templates
Added true single threshold cache strategy and it behaves as expected...
jeandet -
r12:4e36a737f884
parent child
Show More
@@ -0,0 +1,22
1 #ifndef SCIQLOP_SINGLETHRESHOLDCACHESTRATEGY_H
2 #define SCIQLOP_SINGLETHRESHOLDCACHESTRATEGY_H
3
4 #include "Settings/SqpSettingsDefs.h"
5 #include "VariableCacheStrategy.h"
6
7 class SCIQLOP_CORE_EXPORT SingleThresholdCacheStrategy : public VariableCacheStrategy {
8 public:
9 SingleThresholdCacheStrategy() = default;
10
11 DateTimeRange computeRange(const DateTimeRange &currentCacheRange,
12 const DateTimeRange &rangeRequested) override
13 {
14 Q_UNUSED(currentCacheRange);
15 if(currentCacheRange.contains (rangeRequested*1.1))
16 return currentCacheRange;
17 return rangeRequested*2.;
18 }
19 };
20
21
22 #endif // SCIQLOP_SINGLETHRESHOLDCACHESTRATEGY_H
@@ -85,6 +85,7 FILE (GLOB_RECURSE core_SRCS
85 85 ./include/Variable/VariableSynchronizationGroup.h
86 86 ./include/Variable/VariableSynchronizationGroup2.h
87 87 ./include/Variable/ProportionalCacheStrategy.h
88 ./include/Variable/SingleThresholdCacheStrategy.h
88 89 ./include/Variable/VariableCacheStrategyFactory.h
89 90 ./include/Variable/Variable.h
90 91 ./include/Variable/VariableCacheController.h
@@ -2,6 +2,7
2 2 #define SCIQLOP_DATETIMERANGEHELPER_H
3 3
4 4 #include <cmath>
5 #include <variant>
5 6 #include <QObject>
6 7
7 8 #include <QDebug>
@@ -1,5 +1,5
1 #ifndef SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H
2 #define SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H
1 #ifndef SCIQLOP_PROPORTIONALCACHESTRATEGY_H
2 #define SCIQLOP_PROPORTIONALCACHESTRATEGY_H
3 3
4 4 #include "Settings/SqpSettingsDefs.h"
5 5 #include "VariableCacheStrategy.h"
@@ -21,4 +21,4 public:
21 21 };
22 22
23 23
24 #endif // SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H
24 #endif // SCIQLOP_PROPORTIONALCACHESTRATEGY_H
@@ -7,6 +7,7
7 7
8 8 #include "VariableCacheStrategy.h"
9 9 #include "ProportionalCacheStrategy.h"
10 #include "SingleThresholdCacheStrategy.h"
10 11
11 12 #include <Common/debug.h>
12 13 #include <QString>
@@ -27,8 +28,8 public:
27 28 new ProportionalCacheStrategy{}};
28 29 }
29 30 case CacheStrategy::SingleThreshold: {
30 SCIQLOP_ERROR(VariableCacheStrategyFactory, "CacheStrategy::SingleThreshold not implemented yet");
31 break;
31 return std::unique_ptr<VariableCacheStrategy>{
32 new SingleThresholdCacheStrategy{}};
32 33 }
33 34 case CacheStrategy::TwoThreshold: {
34 35 SCIQLOP_ERROR(VariableCacheStrategyFactory, "CacheStrategy::TwoThreshold not implemented yet");
@@ -42,7 +42,7 public:
42 42 */
43 43 void removeVariable(QUuid variable) noexcept
44 44 {
45 this->_variables.extract(variable);
45 this->_variables.erase(variable);
46 46 }
47 47
48 48 /**
@@ -45,12 +45,12 class VariableController2::VariableController2Private
45 45 auto data = provider->getData(DataProviderParameters{{range},var->metadata()});
46 46 var->mergeDataSeries(data);
47 47 }
48 var->setCacheRange(r);
48 var->setCacheRange(newCacheRange);
49 49 var->setRange(r);
50 50 }
51 51 public:
52 52 VariableController2Private(QObject* parent=Q_NULLPTR)
53 :_cacheStrategy(VariableCacheStrategyFactory::createCacheStrategy(CacheStrategy::Proportional))
53 :_cacheStrategy(VariableCacheStrategyFactory::createCacheStrategy(CacheStrategy::SingleThreshold))
54 54 {
55 55 Q_UNUSED(parent);
56 56 }
General Comments 0
You need to be logged in to leave comments. Login now