diff --git a/core/include/Variable/VariableCacheStrategyFactory.h b/core/include/Variable/VariableCacheStrategyFactory.h new file mode 100644 index 0000000..a7ec00c --- /dev/null +++ b/core/include/Variable/VariableCacheStrategyFactory.h @@ -0,0 +1,44 @@ +#ifndef SCIQLOP_VARIABLECACHESTRATEGYFACTORY_H +#define SCIQLOP_VARIABLECACHESTRATEGYFACTORY_H + + +#include +#include + +#include "VariableCacheStrategy.h" +#include "VariableSingleThresholdCacheStrategy.h" + +#include +#include + +Q_LOGGING_CATEGORY(LOG_VariableCacheStrategyFactory, "VariableCacheStrategyFactory") + +enum class CacheStrategy { SingleThreshold, TwoThreashold }; + +class VariableCacheStrategyFactory { + + using cacheStratPtr = std::unique_ptr; + +public: + static cacheStratPtr createCacheStrategy(CacheStrategy specificStrategy) + { + switch (specificStrategy) { + case CacheStrategy::SingleThreshold: { + return std::unique_ptr{ + new VariableSingleThresholdCacheStrategy{}}; + break; + } + case CacheStrategy::TwoThreashold: { + qCCritical(LOG_VariableCacheStrategyFactory()) + << QObject::tr("cache strategy not implemented yet"); + break; + } + default: + qCCritical(LOG_VariableCacheStrategyFactory()) + << QObject::tr("Unknown cache strategy"); + } + } +}; + + +#endif // VARIABLECACHESTRATEGYFACTORY_H diff --git a/core/include/Variable/singlethresholdcachestrategy.h b/core/include/Variable/VariableSingleThresholdCacheStrategy.h similarity index 76% rename from core/include/Variable/singlethresholdcachestrategy.h rename to core/include/Variable/VariableSingleThresholdCacheStrategy.h index 821248e..66be152 100644 --- a/core/include/Variable/singlethresholdcachestrategy.h +++ b/core/include/Variable/VariableSingleThresholdCacheStrategy.h @@ -1,14 +1,14 @@ -#ifndef SINGLETHRESHOLDCACHESTRATEGY_H -#define SINGLETHRESHOLDCACHESTRATEGY_H +#ifndef SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H +#define SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H #include "Settings/SqpSettingsDefs.h" #include "VariableCacheStrategy.h" /// This class aims to hande the cache strategy. -class SCIQLOP_CORE_EXPORT SingleThresholdCacheStrategy : public VariableCacheStrategy { +class SCIQLOP_CORE_EXPORT VariableSingleThresholdCacheStrategy : public VariableCacheStrategy { public: - SingleThresholdCacheStrategy() = default; + VariableSingleThresholdCacheStrategy() = default; std::pair computeRange(const SqpRange &vRange, const SqpRange &rangeRequested) override @@ -29,4 +29,4 @@ public: }; -#endif // SINGLETHRESHOLDCACHESTRATEGY_H +#endif // SCIQLOP_VARIABLESINGLETHRESHOLDCACHESTRATEGY_H diff --git a/core/include/Variable/cachestrategyfactory.h b/core/include/Variable/cachestrategyfactory.h deleted file mode 100644 index e5a4662..0000000 --- a/core/include/Variable/cachestrategyfactory.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef CACHESTRATEGYFACTORY_H -#define CACHESTRATEGYFACTORY_H - - -#include -#include - -#include "VariableCacheStrategy.h" -#include "singlethresholdcachestrategy.h" - - -enum class CacheStrategy { SingleThreshold, TwoThreashold }; - - -class CacheStrategyFactory { - - using cacheStratPtr = std::unique_ptr; - -public: - static cacheStratPtr createCacheStrategy(CacheStrategy specificStrategy) - { - switch (specificStrategy) { - case CacheStrategy::SingleThreshold: - return std::unique_ptr{new SingleThresholdCacheStrategy{}}; - - case CacheStrategy::TwoThreashold: - throw std::runtime_error("cache strategy not implemented yet"); - } - - throw std::runtime_error("Unknown cache strategy"); - } -}; - - -#endif // CACHESTRATEGYFACTORY_H diff --git a/core/src/Variable/VariableCacheStrategy.cpp b/core/src/Variable/VariableCacheStrategy.cpp deleted file mode 100644 index e69de29..0000000 --- a/core/src/Variable/VariableCacheStrategy.cpp +++ /dev/null diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index 4c6e7a8..6fa1b1e 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -1,10 +1,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -81,8 +81,8 @@ struct VariableController::VariableControllerPrivate { m_VariableModel{new VariableModel{parent}}, m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, // m_VariableCacheStrategy{std::make_unique()}, - m_VariableCacheStrategy{ - CacheStrategyFactory::createCacheStrategy(CacheStrategy::SingleThreshold)}, + m_VariableCacheStrategy{VariableCacheStrategyFactory::createCacheStrategy( + CacheStrategy::SingleThreshold)}, m_VariableAcquisitionWorker{std::make_unique()}, q{parent} { @@ -148,8 +148,8 @@ struct VariableController::VariableControllerPrivate { VariableController::VariableController(QObject *parent) : QObject{parent}, impl{spimpl::make_unique_impl(this)} { - qCDebug(LOG_VariableController()) - << tr("VariableController construction") << QThread::currentThread(); + qCDebug(LOG_VariableController()) << tr("VariableController construction") + << QThread::currentThread(); connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this, &VariableController::onAbortProgressRequested); @@ -176,8 +176,8 @@ VariableController::VariableController(QObject *parent) VariableController::~VariableController() { - qCDebug(LOG_VariableController()) - << tr("VariableController destruction") << QThread::currentThread(); + qCDebug(LOG_VariableController()) << tr("VariableController destruction") + << QThread::currentThread(); this->waitForFinish(); } @@ -296,8 +296,8 @@ VariableController::createVariable(const QString &name, const QVariantHash &meta void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) { // TODO check synchronisation and Rescale - qCDebug(LOG_VariableController()) - << "VariableController::onDateTimeOnSelection" << QThread::currentThread()->objectName(); + qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection" + << QThread::currentThread()->objectName(); auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); auto varRequestId = QUuid::createUuid(); @@ -383,9 +383,9 @@ void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier) void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId) { - qCDebug(LOG_VariableController()) - << "TORM: VariableController::onAddSynchronizationGroupId" - << QThread::currentThread()->objectName() << synchronizationGroupId; + qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId" + << QThread::currentThread()->objectName() + << synchronizationGroupId; auto vSynchroGroup = std::make_shared(); impl->m_GroupIdToVariableSynchronizationGroupMap.insert( std::make_pair(synchronizationGroupId, vSynchroGroup)); @@ -400,8 +400,8 @@ void VariableController::onAddSynchronized(std::shared_ptr variable, QUuid synchronizationGroupId) { - qCDebug(LOG_VariableController()) - << "TORM: VariableController::onAddSynchronized" << synchronizationGroupId; + qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronized" + << synchronizationGroupId; auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable); if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { auto groupIdToVSGIt @@ -506,8 +506,8 @@ void VariableController::onRequestDataLoading(QVector // Don't process already processed var if (!variables.contains(var)) { if (var != nullptr) { - qCDebug(LOG_VariableController()) - << "processRequest synchro for" << var->name(); + qCDebug(LOG_VariableController()) << "processRequest synchro for" + << var->name(); auto vSyncRangeRequested = computeSynchroRangeRequested( var->range(), range, groupIdToOldRangeMap.at(gId)); qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested; @@ -601,8 +601,8 @@ void VariableController::VariableControllerPrivate::processRequest(std::shared_p varProvider); if (!varRequestIdCanceled.isNull()) { - qCDebug(LOG_VariableAcquisitionWorker()) - << tr("vsarRequestIdCanceled: ") << varRequestIdCanceled; + qCDebug(LOG_VariableAcquisitionWorker()) << tr("vsarRequestIdCanceled: ") + << varRequestIdCanceled; cancelVariableRequest(varRequestIdCanceled); } } @@ -647,8 +647,8 @@ VariableController::VariableControllerPrivate::findVariable(QUuid vIdentifier) std::shared_ptr VariableController::VariableControllerPrivate::retrieveDataSeries( const QVector acqDataPacketVector) { - qCDebug(LOG_VariableController()) - << tr("TORM: retrieveDataSeries acqDataPacketVector size") << acqDataPacketVector.size(); + qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size") + << acqDataPacketVector.size(); std::shared_ptr dataSeries; if (!acqDataPacketVector.isEmpty()) { dataSeries = acqDataPacketVector[0].m_DateSeries; @@ -665,8 +665,8 @@ void VariableController::VariableControllerPrivate::registerProvider( std::shared_ptr provider) { if (m_ProviderSet.find(provider) == m_ProviderSet.end()) { - qCDebug(LOG_VariableController()) - << tr("Registering of a new provider") << provider->objectName(); + qCDebug(LOG_VariableController()) << tr("Registering of a new provider") + << provider->objectName(); m_ProviderSet.insert(provider); connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::onVariableDataAcquired); @@ -772,8 +772,8 @@ void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) && processVariableUpdate; ++varIdToVarRequestMapIt) { processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate; - qCDebug(LOG_VariableController()) - << tr("updateVariableRequest") << processVariableUpdate; + qCDebug(LOG_VariableController()) << tr("updateVariableRequest") + << processVariableUpdate; } if (processVariableUpdate) { @@ -783,13 +783,13 @@ void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid auto &varRequest = varIdToVarRequestMapIt->second; var->setRange(varRequest.m_RangeRequested); var->setCacheRange(varRequest.m_CacheRangeRequested); - qCDebug(LOG_VariableController()) - << tr("1: onDataProvided") << varRequest.m_RangeRequested; - qCDebug(LOG_VariableController()) - << tr("2: onDataProvided") << varRequest.m_CacheRangeRequested; + qCDebug(LOG_VariableController()) << tr("1: onDataProvided") + << varRequest.m_RangeRequested; + qCDebug(LOG_VariableController()) << tr("2: onDataProvided") + << varRequest.m_CacheRangeRequested; var->mergeDataSeries(varRequest.m_DataSeries); - qCDebug(LOG_VariableController()) - << tr("3: onDataProvided") << varRequest.m_DataSeries->range(); + qCDebug(LOG_VariableController()) << tr("3: onDataProvided") + << varRequest.m_DataSeries->range(); qCDebug(LOG_VariableController()) << tr("4: onDataProvided"); /// @todo MPL: confirm @@ -807,11 +807,11 @@ void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid } // cleaning varRequestId - qCDebug(LOG_VariableController()) - << tr("0: erase REQUEST in MAP ?") << m_VarRequestIdToVarIdVarRequestMap.size(); + qCDebug(LOG_VariableController()) << tr("0: erase REQUEST in MAP ?") + << m_VarRequestIdToVarIdVarRequestMap.size(); m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId); - qCDebug(LOG_VariableController()) - << tr("1: erase REQUEST in MAP ?") << m_VarRequestIdToVarIdVarRequestMap.size(); + qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in MAP ?") + << m_VarRequestIdToVarIdVarRequestMap.size(); } } else {