From 400fcfcc4519c2019454d5f430c272bc3a7ae5bc Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Mon, 23 Nov 2015 09:59:51 +0000 Subject: [PATCH] Some refactoring in SimulatorEngine. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10928 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/simulator/SimulatorEngine.java | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/prism/src/simulator/SimulatorEngine.java b/prism/src/simulator/SimulatorEngine.java index 5f8f20ec..da641845 100644 --- a/prism/src/simulator/SimulatorEngine.java +++ b/prism/src/simulator/SimulatorEngine.java @@ -932,6 +932,17 @@ public class SimulatorEngine extends PrismComponent return transitionList; } + /** + * Get the state for which the simulator is currently supplying information about its transitions. + * Usually, this is the current (final) state of the path. + * But if the user called {@link #computeTransitionsForStep(int step)}, it will be this state instead. + */ + public State getTransitionListState() + { + return (transitionListState == null) ? path.getCurrentState() : transitionListState; + + } + /** * Returns the current number of available choices. */ @@ -1053,10 +1064,7 @@ public class SimulatorEngine extends PrismComponent */ public String getTransitionUpdateString(int index) throws PrismException { - // We need the state containing the transitions. Usually, this is the current (final) state - // of the path. But if the user called computeTransitionsForStep(int step), this is not so. - State state = (transitionListState == null) ? path.getCurrentState() : transitionListState; - return getTransitionList().getTransitionUpdateString(index, state); + return getTransitionList().getTransitionUpdateString(index, getTransitionListState()); } /** @@ -1076,10 +1084,7 @@ public class SimulatorEngine extends PrismComponent */ public State computeTransitionTarget(int i, int offset) throws PrismException { - // We need the state containing the transitions. Usually, this is the current (final) state - // of the path. But if the user called computeTransitionsForStep(int step), this is not so. - State state = (transitionListState == null) ? path.getCurrentState() : transitionListState; - return getTransitionList().getChoice(i).computeTarget(offset, state); + return getTransitionList().getChoice(i).computeTarget(offset, getTransitionListState()); } /** @@ -1087,10 +1092,7 @@ public class SimulatorEngine extends PrismComponent */ public State computeTransitionTarget(int index) throws PrismException { - // We need the state containing the transitions. Usually, this is the current (final) state - // of the path. But if the user called computeTransitionsForStep(int step), this is not so. - State state = (transitionListState == null) ? path.getCurrentState() : transitionListState; - return getTransitionList().computeTransitionTarget(index, state); + return getTransitionList().computeTransitionTarget(index, getTransitionListState()); } // ------------------------------------------------------------------------------