##// END OF EJS Templates
Variable deletion (2)...
Alexandre Leroux -
r331:d786589b2e4c
parent child
Show More
@@ -1,6 +1,7
1 1 #ifndef SCIQLOP_VARIABLECACHECONTROLLER_H
2 2 #define SCIQLOP_VARIABLECACHECONTROLLER_H
3 3
4 #include <QLoggingCategory>
4 5 #include <QObject>
5 6
6 7 #include <Data/SqpDateTime.h>
@@ -9,6 +10,8
9 10
10 11 #include <Common/spimpl.h>
11 12
13 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheController)
14
12 15 class Variable;
13 16
14 17 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheController)
@@ -23,6 +26,9 public:
23 26
24 27 void addDateTime(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime);
25 28
29 /// Clears cache concerning a variable
30 void clear(std::shared_ptr<Variable> variable) noexcept;
31
26 32 /// Return all of the SqpDataTime part of the dateTime whose are not in the cache
27 33 QVector<SqpDateTime> provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable,
28 34 const SqpDateTime &dateTime);
@@ -35,6 +35,7 public:
35 35 *
36 36 * Delete a variable includes:
37 37 * - the deletion of the provider associated with the variable
38 * - removing the cache associated with the variable
38 39 *
39 40 * @param variable the variable to delete from the controller.
40 41 */
@@ -61,6 +61,22 void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable,
61 61 }
62 62 }
63 63
64 void VariableCacheController::clear(std::shared_ptr<Variable> variable) noexcept
65 {
66 if (!variable) {
67 qCCritical(LOG_VariableCacheController()) << "Can't clear variable cache: variable is null";
68 return;
69 }
70
71 auto nbEntries = impl->m_VariableToSqpDateTimeListMap.erase(variable);
72
73 auto clearCacheMessage
74 = (nbEntries != 0)
75 ? tr("Variable cache cleared for variable %1").arg(variable->name())
76 : tr("No deletion of variable cache: no cache was associated with the variable");
77 qCDebug(LOG_VariableCacheController()) << clearCacheMessage;
78 }
79
64 80 QVector<SqpDateTime>
65 81 VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable,
66 82 const SqpDateTime &dateTime)
@@ -96,6 +96,9 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noex
96 96 << tr("Number of providers deleted for variable %1: %2")
97 97 .arg(variable->name(), QString::number(nbProvidersDeleted));
98 98
99 // Clears cache
100 impl->m_VariableCacheController->clear(variable);
101
99 102
100 103 void VariableController::deleteVariables(
101 104 const QVector<std::shared_ptr<Variable> > &variables) noexcept
General Comments 0
You need to be logged in to leave comments. Login now