##// END OF EJS Templates
Updates states of synchronized variables when there is a move operation
Alexandre Leroux -
r1209:162d6112469c
parent child
Show More
@@ -81,7 +81,8 void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId sync
81 81 return;
82 82 }
83 83
84 // Unregisters variable from sync group: if there is no more variable in the group, resets the range
84 // Unregisters variable from sync group: if there is no more variable in the group, resets the
85 // range
85 86 auto &syncGroup = m_SyncGroupsPool.at(syncGroupId);
86 87 syncGroup.m_Variables.erase(variableId);
87 88 if (syncGroup.m_Variables.empty()) {
@@ -89,3 +90,18 void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId sync
89 90 }
90 91 }
91 92
93 void FuzzingState::updateRanges(VariableId variableId, const SqpRange &newRange)
94 {
95 auto syncGroupId = this->syncGroupId(variableId);
96
97 // Retrieves the variables to update:
98 // - if the variable is synchronized to others, updates all synchronized variables
99 // - otherwise, updates only the variable
100 auto variablesToUpdate = syncGroupId.isNull() ? std::set<VariableId>{variableId}
101 : m_SyncGroupsPool.at(syncGroupId).m_Variables;
102
103 // Sets new range
104 for (const auto &variableId : variablesToUpdate) {
105 m_VariablesPool.at(variableId).m_Range = newRange;
106 }
107 }
@@ -110,6 +110,10 struct FuzzingState {
110 110 /// @param syncGroupId the synchronization group from which to remove the variable
111 111 void desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId);
112 112
113 /// Updates the range of a variable and all variables to which it is synchronized
114 /// @param the variable for which to affect the range
115 /// @param the range to affect
116 void updateRanges(VariableId variableId, const SqpRange &newRange);
113 117
114 118 VariablesPool m_VariablesPool;
115 119 SyncGroupsPool m_SyncGroupsPool;
@@ -136,15 +136,16 struct MoveOperation : public IFuzzingOperation {
136 136 auto delta = RandomGenerator::instance().generateDouble(0, deltaMax);
137 137
138 138 // Moves variable to its new range
139 auto isSynchronized = !fuzzingState.syncGroupId(variableId).isNull();
139 140 auto newVariableRange = SqpRange{m_RangeStartMoveFun(variableRange.m_TStart, delta),
140 141 m_RangeEndMoveFun(variableRange.m_TEnd, delta)};
141 142 qCInfo(LOG_FuzzingOperations()).noquote()
142 143 << "Performing" << m_Label << "on" << variable->name() << "(from" << variableRange
143 144 << "to" << newVariableRange << ")...";
144 variableController.onRequestDataLoading({variable}, newVariableRange, false);
145 variableController.onRequestDataLoading({variable}, newVariableRange, isSynchronized);
145 146
146 // Updates variable's state
147 variableState.m_Range = newVariableRange;
147 // Updates state
148 fuzzingState.updateRanges(variableId, newVariableRange);
148 149 }
149 150
150 151 MoveFunction m_RangeStartMoveFun;
General Comments 0
You need to be logged in to leave comments. Login now