MCPcopy Create free account
hub / github.com/MITK/MITK / GetExecutableTransition

Method GetExecutableTransition

Modules/Core/src/Interactions/mitkEventStateMachine.cpp:202–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202mitk::StateMachineTransition *mitk::EventStateMachine::GetExecutableTransition(mitk::InteractionEvent *event)
203{
204 // Map that will contain all conditions that are possibly used by the
205 // transitions
206 std::map<std::string, bool> conditionsMap;
207
208 // Get a list of all transitions that match the given event
209 const mitk::StateMachineState::TransitionVector transitionList =
210 m_CurrentState->GetTransitionList(event->GetNameOfClass(), MapToEventVariant(event));
211
212 // if there are not transitions, we can return nullptr here.
213 if (transitionList.empty())
214 {
215 return nullptr;
216 }
217
218 StateMachineState::TransitionVector::const_iterator transitionIter;
219 ConditionVectorType::const_iterator conditionIter;
220 for (transitionIter = transitionList.cbegin(); transitionIter != transitionList.cend(); ++transitionIter)
221 {
222 bool allConditionsFulfilled(true);
223
224 // Get all conditions for the current transition
225 const ConditionVectorType conditions = (*transitionIter)->GetConditions();
226 for (conditionIter = conditions.cbegin(); conditionIter != conditions.cend(); ++conditionIter)
227 {
228 bool currentConditionFulfilled(false);
229
230 // sequentially check all conditions that we have evaluated above
231 const std::string conditionName = (*conditionIter).GetConditionName();
232
233 // Check if the condition has already been evaluated
234 if (conditionsMap.find(conditionName) == conditionsMap.cend())
235 {
236 // if the condition has not been evaluated yet, do it now and store
237 // the result in the map
238 try
239 {
240 currentConditionFulfilled = CheckCondition((*conditionIter), event);
241 conditionsMap.insert(std::pair<std::string, bool>(conditionName, currentConditionFulfilled));
242 }
243 catch (const std::exception &e)
244 {
245 MITK_ERROR << "Unhandled exception caught in CheckCondition(): " << e.what();
246 currentConditionFulfilled = false;
247 break;
248 }
249 catch (...)
250 {
251 MITK_ERROR << "Unhandled exception caught in CheckCondition()";
252 currentConditionFulfilled = false;
253 break;
254 }
255 }
256 else
257 {
258 // if the condition has been evaluated before, use that result
259 currentConditionFulfilled = conditionsMap[conditionName];

Callers

nothing calls this directly

Calls 7

GetTransitionListMethod · 0.80
GetConditionNameMethod · 0.80
whatMethod · 0.80
IsInvertedMethod · 0.80
GetNameOfClassMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected