##// END OF EJS Templates
@@ -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
@@ -1,14 +1,14
1 #ifndef SINGLETHRESHOLDCACHESTRATEGY_H
2 #define SINGLETHRESHOLDCACHESTRATEGY_H
1 #ifndef SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H
2 #define SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H
3 3
4 4 #include "Settings/SqpSettingsDefs.h"
5 5 #include "VariableCacheStrategy.h"
6 6
7 7
8 8 /// This class aims to hande the cache strategy.
9 class SCIQLOP_CORE_EXPORT SingleThresholdCacheStrategy : public VariableCacheStrategy {
9 class SCIQLOP_CORE_EXPORT VariableSingleThresholdCacheStrategy : public VariableCacheStrategy {
10 10 public:
11 SingleThresholdCacheStrategy() = default;
11 VariableSingleThresholdCacheStrategy() = default;
12 12
13 13 std::pair<SqpRange, SqpRange> computeRange(const SqpRange &vRange,
14 14 const SqpRange &rangeRequested) override
@@ -29,4 +29,4 public:
29 29 };
30 30
31 31
32 #endif // SINGLETHRESHOLDCACHESTRATEGY_H
32 #endif // SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H
@@ -1,10 +1,10
1 1 #include <Variable/Variable.h>
2 2 #include <Variable/VariableAcquisitionWorker.h>
3 3 #include <Variable/VariableCacheStrategy.h>
4 #include <Variable/VariableCacheStrategyFactory.h>
4 5 #include <Variable/VariableController.h>
5 6 #include <Variable/VariableModel.h>
6 7 #include <Variable/VariableSynchronizationGroup.h>
7 #include <Variable/cachestrategyfactory.h>
8 8
9 9 #include <Data/DataProviderParameters.h>
10 10 #include <Data/IDataProvider.h>
@@ -81,8 +81,8 struct VariableController::VariableControllerPrivate {
81 81 m_VariableModel{new VariableModel{parent}},
82 82 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
83 83 // m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()},
84 m_VariableCacheStrategy{
85 CacheStrategyFactory::createCacheStrategy(CacheStrategy::SingleThreshold)},
84 m_VariableCacheStrategy{VariableCacheStrategyFactory::createCacheStrategy(
85 CacheStrategy::SingleThreshold)},
86 86 m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()},
87 87 q{parent}
88 88 {
@@ -148,8 +148,8 struct VariableController::VariableControllerPrivate {
148 148 VariableController::VariableController(QObject *parent)
149 149 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
150 150 {
151 qCDebug(LOG_VariableController())
152 << tr("VariableController construction") << QThread::currentThread();
151 qCDebug(LOG_VariableController()) << tr("VariableController construction")
152 << QThread::currentThread();
153 153
154 154 connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this,
155 155 &VariableController::onAbortProgressRequested);
@@ -176,8 +176,8 VariableController::VariableController(QObject *parent)
176 176
177 177 VariableController::~VariableController()
178 178 {
179 qCDebug(LOG_VariableController())
180 << tr("VariableController destruction") << QThread::currentThread();
179 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
180 << QThread::currentThread();
181 181 this->waitForFinish();
182 182 }
183 183
@@ -296,8 +296,8 VariableController::createVariable(const QString &name, const QVariantHash &meta
296 296 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
297 297 {
298 298 // TODO check synchronisation and Rescale
299 qCDebug(LOG_VariableController())
300 << "VariableController::onDateTimeOnSelection" << QThread::currentThread()->objectName();
299 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
300 << QThread::currentThread()->objectName();
301 301 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
302 302 auto varRequestId = QUuid::createUuid();
303 303
@@ -383,9 +383,9 void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier)
383 383
384 384 void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId)
385 385 {
386 qCDebug(LOG_VariableController())
387 << "TORM: VariableController::onAddSynchronizationGroupId"
388 << QThread::currentThread()->objectName() << synchronizationGroupId;
386 qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId"
387 << QThread::currentThread()->objectName()
388 << synchronizationGroupId;
389 389 auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>();
390 390 impl->m_GroupIdToVariableSynchronizationGroupMap.insert(
391 391 std::make_pair(synchronizationGroupId, vSynchroGroup));
@@ -400,8 +400,8 void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable,
400 400 QUuid synchronizationGroupId)
401 401
402 402 {
403 qCDebug(LOG_VariableController())
404 << "TORM: VariableController::onAddSynchronized" << synchronizationGroupId;
403 qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronized"
404 << synchronizationGroupId;
405 405 auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable);
406 406 if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) {
407 407 auto groupIdToVSGIt
@@ -506,8 +506,8 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
506 506 // Don't process already processed var
507 507 if (!variables.contains(var)) {
508 508 if (var != nullptr) {
509 qCDebug(LOG_VariableController())
510 << "processRequest synchro for" << var->name();
509 qCDebug(LOG_VariableController()) << "processRequest synchro for"
510 << var->name();
511 511 auto vSyncRangeRequested = computeSynchroRangeRequested(
512 512 var->range(), range, groupIdToOldRangeMap.at(gId));
513 513 qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested;
@@ -601,8 +601,8 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
601 601 varProvider);
602 602
603 603 if (!varRequestIdCanceled.isNull()) {
604 qCDebug(LOG_VariableAcquisitionWorker())
605 << tr("vsarRequestIdCanceled: ") << varRequestIdCanceled;
604 qCDebug(LOG_VariableAcquisitionWorker()) << tr("vsarRequestIdCanceled: ")
605 << varRequestIdCanceled;
606 606 cancelVariableRequest(varRequestIdCanceled);
607 607 }
608 608 }
@@ -647,8 +647,8 VariableController::VariableControllerPrivate::findVariable(QUuid vIdentifier)
647 647 std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries(
648 648 const QVector<AcquisitionDataPacket> acqDataPacketVector)
649 649 {
650 qCDebug(LOG_VariableController())
651 << tr("TORM: retrieveDataSeries acqDataPacketVector size") << acqDataPacketVector.size();
650 qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size")
651 << acqDataPacketVector.size();
652 652 std::shared_ptr<IDataSeries> dataSeries;
653 653 if (!acqDataPacketVector.isEmpty()) {
654 654 dataSeries = acqDataPacketVector[0].m_DateSeries;
@@ -665,8 +665,8 void VariableController::VariableControllerPrivate::registerProvider(
665 665 std::shared_ptr<IDataProvider> provider)
666 666 {
667 667 if (m_ProviderSet.find(provider) == m_ProviderSet.end()) {
668 qCDebug(LOG_VariableController())
669 << tr("Registering of a new provider") << provider->objectName();
668 qCDebug(LOG_VariableController()) << tr("Registering of a new provider")
669 << provider->objectName();
670 670 m_ProviderSet.insert(provider);
671 671 connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(),
672 672 &VariableAcquisitionWorker::onVariableDataAcquired);
@@ -772,8 +772,8 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid
772 772 (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) && processVariableUpdate;
773 773 ++varIdToVarRequestMapIt) {
774 774 processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate;
775 qCDebug(LOG_VariableController())
776 << tr("updateVariableRequest") << processVariableUpdate;
775 qCDebug(LOG_VariableController()) << tr("updateVariableRequest")
776 << processVariableUpdate;
777 777 }
778 778
779 779 if (processVariableUpdate) {
@@ -783,13 +783,13 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid
783 783 auto &varRequest = varIdToVarRequestMapIt->second;
784 784 var->setRange(varRequest.m_RangeRequested);
785 785 var->setCacheRange(varRequest.m_CacheRangeRequested);
786 qCDebug(LOG_VariableController())
787 << tr("1: onDataProvided") << varRequest.m_RangeRequested;
788 qCDebug(LOG_VariableController())
789 << tr("2: onDataProvided") << varRequest.m_CacheRangeRequested;
786 qCDebug(LOG_VariableController()) << tr("1: onDataProvided")
787 << varRequest.m_RangeRequested;
788 qCDebug(LOG_VariableController()) << tr("2: onDataProvided")
789 << varRequest.m_CacheRangeRequested;
790 790 var->mergeDataSeries(varRequest.m_DataSeries);
791 qCDebug(LOG_VariableController())
792 << tr("3: onDataProvided") << varRequest.m_DataSeries->range();
791 qCDebug(LOG_VariableController()) << tr("3: onDataProvided")
792 << varRequest.m_DataSeries->range();
793 793 qCDebug(LOG_VariableController()) << tr("4: onDataProvided");
794 794
795 795 /// @todo MPL: confirm
@@ -807,11 +807,11 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid
807 807 }
808 808
809 809 // cleaning varRequestId
810 qCDebug(LOG_VariableController())
811 << tr("0: erase REQUEST in MAP ?") << m_VarRequestIdToVarIdVarRequestMap.size();
810 qCDebug(LOG_VariableController()) << tr("0: erase REQUEST in MAP ?")
811 << m_VarRequestIdToVarIdVarRequestMap.size();
812 812 m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId);
813 qCDebug(LOG_VariableController())
814 << tr("1: erase REQUEST in MAP ?") << m_VarRequestIdToVarIdVarRequestMap.size();
813 qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in MAP ?")
814 << m_VarRequestIdToVarIdVarRequestMap.size();
815 815 }
816 816 }
817 817 else {
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now