@@ -0,0 +1,44 | |||||
|
1 | #ifndef SCIQLOP_VARIABLECACHESTRATEGYFACTORY_H | |||
|
2 | #define SCIQLOP_VARIABLECACHESTRATEGYFACTORY_H | |||
|
3 | ||||
|
4 | ||||
|
5 | #include <memory> | |||
|
6 | #include <stdexcept> | |||
|
7 | ||||
|
8 | #include "VariableCacheStrategy.h" | |||
|
9 | #include "VariableSingleThresholdCacheStrategy.h" | |||
|
10 | ||||
|
11 | #include <QLoggingCategory> | |||
|
12 | #include <QString> | |||
|
13 | ||||
|
14 | Q_LOGGING_CATEGORY(LOG_VariableCacheStrategyFactory, "VariableCacheStrategyFactory") | |||
|
15 | ||||
|
16 | enum class CacheStrategy { SingleThreshold, TwoThreashold }; | |||
|
17 | ||||
|
18 | class VariableCacheStrategyFactory { | |||
|
19 | ||||
|
20 | using cacheStratPtr = std::unique_ptr<VariableCacheStrategy>; | |||
|
21 | ||||
|
22 | public: | |||
|
23 | static cacheStratPtr createCacheStrategy(CacheStrategy specificStrategy) | |||
|
24 | { | |||
|
25 | switch (specificStrategy) { | |||
|
26 | case CacheStrategy::SingleThreshold: { | |||
|
27 | return std::unique_ptr<VariableCacheStrategy>{ | |||
|
28 | new VariableSingleThresholdCacheStrategy{}}; | |||
|
29 | break; | |||
|
30 | } | |||
|
31 | case CacheStrategy::TwoThreashold: { | |||
|
32 | qCCritical(LOG_VariableCacheStrategyFactory()) | |||
|
33 | << QObject::tr("cache strategy not implemented yet"); | |||
|
34 | break; | |||
|
35 | } | |||
|
36 | default: | |||
|
37 | qCCritical(LOG_VariableCacheStrategyFactory()) | |||
|
38 | << QObject::tr("Unknown cache strategy"); | |||
|
39 | } | |||
|
40 | } | |||
|
41 | }; | |||
|
42 | ||||
|
43 | ||||
|
44 | #endif // VARIABLECACHESTRATEGYFACTORY_H |
@@ -0,0 +1,32 | |||||
|
1 | #ifndef SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H | |||
|
2 | #define SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H | |||
|
3 | ||||
|
4 | #include "Settings/SqpSettingsDefs.h" | |||
|
5 | #include "VariableCacheStrategy.h" | |||
|
6 | ||||
|
7 | ||||
|
8 | /// This class aims to hande the cache strategy. | |||
|
9 | class SCIQLOP_CORE_EXPORT VariableSingleThresholdCacheStrategy : public VariableCacheStrategy { | |||
|
10 | public: | |||
|
11 | VariableSingleThresholdCacheStrategy() = default; | |||
|
12 | ||||
|
13 | std::pair<SqpRange, SqpRange> computeRange(const SqpRange &vRange, | |||
|
14 | const SqpRange &rangeRequested) override | |||
|
15 | { | |||
|
16 | ||||
|
17 | auto varRanges = std::pair<SqpRange, SqpRange>{}; | |||
|
18 | ||||
|
19 | auto toleranceFactor = SqpSettings::toleranceValue( | |||
|
20 | GENERAL_TOLERANCE_AT_UPDATE_KEY, GENERAL_TOLERANCE_AT_UPDATE_DEFAULT_VALUE); | |||
|
21 | auto tolerance = toleranceFactor * (rangeRequested.m_TEnd - rangeRequested.m_TStart); | |||
|
22 | ||||
|
23 | varRanges.first = rangeRequested; | |||
|
24 | varRanges.second | |||
|
25 | = SqpRange{rangeRequested.m_TStart - tolerance, rangeRequested.m_TEnd + tolerance}; | |||
|
26 | ||||
|
27 | return varRanges; | |||
|
28 | } | |||
|
29 | }; | |||
|
30 | ||||
|
31 | ||||
|
32 | #endif // SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H |
@@ -18,23 +18,14 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheStrategy) | |||||
18 |
|
18 | |||
19 | class Variable; |
|
19 | class Variable; | |
20 |
|
20 | |||
21 | /** |
|
|||
22 | * Possible types of zoom operation |
|
|||
23 | */ |
|
|||
24 | enum class CacheStrategy { FixedTolerance, TwoThreashold }; |
|
|||
25 |
|
||||
26 | /// This class aims to hande the cache strategy. |
|
21 | /// This class aims to hande the cache strategy. | |
27 |
class SCIQLOP_CORE_EXPORT VariableCacheStrategy |
|
22 | class SCIQLOP_CORE_EXPORT VariableCacheStrategy { | |
28 | Q_OBJECT |
|
|||
29 | public: |
|
|||
30 | explicit VariableCacheStrategy(QObject *parent = 0); |
|
|||
31 |
|
||||
32 | std::pair<SqpRange, SqpRange> computeStrategyRanges(const SqpRange &vRange, |
|
|||
33 | const SqpRange &rangeRequested); |
|
|||
34 |
|
23 | |||
35 | private: |
|
24 | public: | |
36 | class VariableCacheStrategyPrivate; |
|
25 | virtual std::pair<SqpRange, SqpRange> computeRange(const SqpRange &vRange, | |
37 | spimpl::unique_impl_ptr<VariableCacheStrategyPrivate> impl; |
|
26 | const SqpRange &rangeRequested) | |
|
27 | = 0; | |||
38 | }; |
|
28 | }; | |
39 |
|
29 | |||
|
30 | ||||
40 | #endif // SCIQLOP_VARIABLECACHESTRATEGY_H |
|
31 | #endif // SCIQLOP_VARIABLECACHESTRATEGY_H |
@@ -33,7 +33,7 std::vector<double> flatten(std::vector<double> xValues, std::vector<double> yVa | |||||
33 | result.push_back(xValues[i]); |
|
33 | result.push_back(xValues[i]); | |
34 | result.push_back(yValues[i]); |
|
34 | result.push_back(yValues[i]); | |
35 | result.push_back(zValues[i]); |
|
35 | result.push_back(zValues[i]); | |
36 |
|
|
36 | } | |
37 |
|
37 | |||
38 | return result; |
|
38 | return result; | |
39 | } |
|
39 | } |
@@ -1,6 +1,7 | |||||
1 | #include <Variable/Variable.h> |
|
1 | #include <Variable/Variable.h> | |
2 | #include <Variable/VariableAcquisitionWorker.h> |
|
2 | #include <Variable/VariableAcquisitionWorker.h> | |
3 | #include <Variable/VariableCacheStrategy.h> |
|
3 | #include <Variable/VariableCacheStrategy.h> | |
|
4 | #include <Variable/VariableCacheStrategyFactory.h> | |||
4 | #include <Variable/VariableController.h> |
|
5 | #include <Variable/VariableController.h> | |
5 | #include <Variable/VariableModel.h> |
|
6 | #include <Variable/VariableModel.h> | |
6 | #include <Variable/VariableSynchronizationGroup.h> |
|
7 | #include <Variable/VariableSynchronizationGroup.h> | |
@@ -79,7 +80,9 struct VariableController::VariableControllerPrivate { | |||||
79 | : m_WorkingMutex{}, |
|
80 | : m_WorkingMutex{}, | |
80 | m_VariableModel{new VariableModel{parent}}, |
|
81 | m_VariableModel{new VariableModel{parent}}, | |
81 | m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, |
|
82 | m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, | |
82 | m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()}, |
|
83 | // m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()}, | |
|
84 | m_VariableCacheStrategy{VariableCacheStrategyFactory::createCacheStrategy( | |||
|
85 | CacheStrategy::SingleThreshold)}, | |||
83 | m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()}, |
|
86 | m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()}, | |
84 | q{parent} |
|
87 | q{parent} | |
85 | { |
|
88 | { | |
@@ -573,7 +576,7 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||||
573 | auto varId = m_VariableToIdentifierMap.at(var); |
|
576 | auto varId = m_VariableToIdentifierMap.at(var); | |
574 |
|
577 | |||
575 | auto varStrategyRangesRequested |
|
578 | auto varStrategyRangesRequested | |
576 |
= m_VariableCacheStrategy->compute |
|
579 | = m_VariableCacheStrategy->computeRange(var->range(), rangeRequested); | |
577 |
|
580 | |||
578 | auto notInCacheRangeList = QVector<SqpRange>{varStrategyRangesRequested.second}; |
|
581 | auto notInCacheRangeList = QVector<SqpRange>{varStrategyRangesRequested.second}; | |
579 | auto inCacheRangeList = QVector<SqpRange>{}; |
|
582 | auto inCacheRangeList = QVector<SqpRange>{}; |
@@ -22,8 +22,8 gui_ui_files = [ | |||||
22 | 'ui/SidePane/SqpSidePane.ui', |
|
22 | 'ui/SidePane/SqpSidePane.ui', | |
23 | 'ui/TimeWidget/TimeWidget.ui', |
|
23 | 'ui/TimeWidget/TimeWidget.ui', | |
24 | 'ui/Variable/VariableInspectorWidget.ui', |
|
24 | 'ui/Variable/VariableInspectorWidget.ui', | |
25 | 'ui/Variable/VariableMenuHeaderWidget.ui', |
|
|||
26 | 'ui/Variable/RenameVariableDialog.ui', |
|
25 | 'ui/Variable/RenameVariableDialog.ui', | |
|
26 | 'ui/Variable/VariableMenuHeaderWidget.ui', | |||
27 | 'ui/Visualization/VisualizationGraphWidget.ui', |
|
27 | 'ui/Visualization/VisualizationGraphWidget.ui', | |
28 | 'ui/Visualization/VisualizationTabWidget.ui', |
|
28 | 'ui/Visualization/VisualizationTabWidget.ui', | |
29 | 'ui/Visualization/VisualizationWidget.ui', |
|
29 | 'ui/Visualization/VisualizationWidget.ui', |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now