##// END OF EJS Templates
commit
Alexandre Leroux -
r684:90684a2a46fa
parent child
Show More
@@ -29,6 +29,7 public:
29 29 explicit VariableAcquisitionWorker(QObject *parent = 0);
30 30 virtual ~VariableAcquisitionWorker();
31 31
32 void cancelVariableRequest(std::shared_ptr<Variable> variable);
32 33 void pushVariableRequest(std::shared_ptr<Variable> variable, VariableRequest request);
33 34
34 35 void abortProgressRequested(QUuid vIdentifier);
@@ -48,12 +48,11 public:
48 48 void removeGroup(GroupId groupId) noexcept;
49 49
50 50 /**
51 * Removes a variable from a synchronization group. If the synchronization group doesn't exist
52 * or if the variable isn't in it, the method does nothing
51 * Removes a variable from its synchronization group. If the variable isn't in a synchronization
52 * group, the method does nothing
53 53 * @param variable the variable to desynchronize
54 * @param groupId the synchronization group identifier
55 54 */
56 void removeVariable(std::shared_ptr<Variable> variable, GroupId groupId) noexcept;
55 void removeVariable(std::shared_ptr<Variable> variable) noexcept;
57 56
58 57 /// @return the variables in the same group than the variable passed as a parameter (including
59 58 /// the variable)
@@ -83,6 +83,11 VariableAcquisitionWorker::~VariableAcquisitionWorker()
83 83 this->waitForFinish();
84 84 }
85 85
86 void VariableAcquisitionWorker::cancelVariableRequest(std::shared_ptr<Variable> variable)
87 {
88 /// @todo ALX
89 }
90
86 91 void VariableAcquisitionWorker::pushVariableRequest(std::shared_ptr<Variable> variable,
87 92 VariableRequest request)
88 93 {
@@ -138,8 +143,6 void VariableAcquisitionWorker::onDataAcquired(QUuid acquisitionId,
138 143 auto &acquisition = it->second;
139 144 auto &request = acquisition.m_Request;
140 145
141 qInfo(LOG_VariableAcquisitionWorker()) << "Data acquired for " << printRange(range);
142
143 146 // Store the result
144 147 request.addResult(dataSeries);
145 148
@@ -250,6 +250,12 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noex
250 250 // make some treatments before the deletion
251 251 emit variableAboutToBeDeleted(variable);
252 252
253 // Deletes from synchronization group
254 impl->m_VariableSynchronizer->removeVariable(variable);
255
256 // Cancels pending requests
257 impl->m_VariableAcquisitionWorker->cancelVariableRequest(variable);
258
253 259 // Deletes provider
254 260 auto nbProvidersDeleted = impl->m_Providers.erase(variable);
255 261 qCDebug(LOG_VariableController())
@@ -380,7 +386,9 void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable,
380 386 void VariableController::desynchronize(std::shared_ptr<Variable> variable,
381 387 QUuid synchronizationGroupId)
382 388 {
383 impl->m_VariableSynchronizer->removeVariable(variable, synchronizationGroupId);
389 // As a variable can't be into more than one synchronization group,we don't need group id here
390 Q_UNUSED(synchronizationGroupId);
391 impl->m_VariableSynchronizer->removeVariable(variable);
384 392 }
385 393
386 394 void VariableController::onRequestDataLoading(const QVector<std::shared_ptr<Variable> > &variables,
@@ -7,7 +7,10 Q_LOGGING_CATEGORY(LOG_VariableSynchronizer, "VariableSynchronizer")
7 7 namespace {
8 8
9 9 using GroupId = VariableSynchronizer::GroupId;
10 using Group = std::set<std::shared_ptr<Variable> >;
10 struct Group {
11 GroupId m_Id;
12 std::set<std::shared_ptr<Variable> > m_Variables;
13 };
11 14
12 15 } // namespace
13 16
@@ -52,7 +55,7 void VariableSynchronizer::addVariable(std::shared_ptr<Variable> variable, Group
52 55 }
53 56
54 57 // Registers variable
55 groupIt->second.insert(variable);
58 groupIt->second.m_Variables.insert(variable);
56 59
57 60 // Creates index for variable
58 61 impl->m_GroupsIndex.insert(std::make_pair(variable, &groupIt->second));
@@ -69,7 +72,7 void VariableSynchronizer::removeGroup(GroupId groupId) noexcept
69 72 }
70 73
71 74 // Removes indexes
72 for (const auto &variable : groupIt->second) {
75 for (const auto &variable : groupIt->second.m_Variables) {
73 76 impl->m_GroupsIndex.erase(variable);
74 77 }
75 78
@@ -77,29 +80,25 void VariableSynchronizer::removeGroup(GroupId groupId) noexcept
77 80 impl->m_Groups.erase(groupIt);
78 81 }
79 82
80 void VariableSynchronizer::removeVariable(std::shared_ptr<Variable> variable,
81 GroupId groupId) noexcept
83 void VariableSynchronizer::removeVariable(std::shared_ptr<Variable> variable) noexcept
82 84 {
83 auto groupIt = impl->m_Groups.find(groupId);
85 // Finds group in which the variable is
86 auto variableGroupIt = impl->m_GroupsIndex.find(variable);
87 if (variableGroupIt != impl->m_GroupsIndex.end()) {
88 auto groupId = variableGroupIt->second->m_Id;
84 89
85 if (groupIt == impl->m_Groups.end()) {
86 qCWarning(LOG_VariableSynchronizer())
87 << tr("Can't remove variable from synchronization group: no group exists under the "
88 "passed identifier");
89 return;
90 }
90 // Removes variable index
91 impl->m_GroupsIndex.erase(variableGroupIt);
91 92
92 // Removes variable index
93 impl->m_GroupsIndex.erase(variable);
94
95 // Removes variable from group
96 groupIt->second.erase(variable);
93 // Removes variable from group
94 impl->m_Groups[groupId].m_Variables.erase(variable);
95 }
97 96 }
98 97
99 98 std::set<std::shared_ptr<Variable> >
100 99 VariableSynchronizer::synchronizedVariables(std::shared_ptr<Variable> variable) const noexcept
101 100 {
102 101 auto groupIndexIt = impl->m_GroupsIndex.find(variable);
103 return groupIndexIt != impl->m_GroupsIndex.end() ? *groupIndexIt->second
102 return groupIndexIt != impl->m_GroupsIndex.end() ? groupIndexIt->second->m_Variables
104 103 : std::set<std::shared_ptr<Variable> >{};
105 104 }
General Comments 0
You need to be logged in to leave comments. Login now