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