Re: test for default history content

Zjnue,
   One other note on the question of addDescendentStatesToEnter, I was 
thinking that either we should rename this function to make it clear 
that it should add the state as well as its descendents, or we should 
have computeEntrySet add the state before calling addDescendentStates.  
Do you have an opinion as to which would be better?

- Jim
On 4/1/2014 5:51 AM, Zjnue Brzavi wrote:
> [...]
>
>     what if we define
>
>     getTargetStates(stateList, defaultEntryContent)
>         allTargets = newOrderedSet
>         for state in stateList:
>              if isHistoryState(state):
>                   if historyValue[state.id <http://state.id>]:
>                        allTargets.union(historyValue[state.id
>     <http://state.id>])
>                   else:
>     allTargets.union(getTargetStates(state.transition.target))
>                       defaultHistoryContent[state.parent.id
>     <http://state.parent.id>] = state.transition.content
>              else:
>                  allTargets.add(state)
>
>     If we do this, addDescendentStatesToEnter should never see a
>     history state, so it can be simplified to:
>
>     procedure addDescendantStatesToEnter(state,statesToEnter,statesForDefaultEntry, defaultHistoryContent):
>          if isCompoundState(state):
>              statesForDefaultEntry.add(state)
>              for s in getTargetStates(state.initial):
>                 statesToEnter.add(s)
>                 addDescendantStatesToEnter(s,statesToEnter,statesForDefaultEntry)
>                 addAncestorStatesToEnter(s, state, statesToEnter, statesForDefaultEntry, defaultHistoryContent)
>          elif isParallelState(state):
>               for child in getChildStates(state):
>                   if not statesToEnter.some(lambda s: isDescendant(s,child)):
>                      statesToEnter.add(child)
>                      addDescendantStatesToEnter(child,statesToEnter,statesForDefaultEntry, defaultHistoryContent)
>
> Hi,
>
> Please excuse the wait - only just found time this morning to test the 
> suggested changes.
> After two small alterations, they work well.
>
> It is important to remember that we call getTargetStates from several 
> places where we don't have a reference to defaultHistoryContent. 
> Therefore, the argument is optional and we need to test whether 
> defaultHistoryContent is null before trying to populate it.
>
> Secondly, addDescendantStatesToEnter should call 
> statesToEnter.add(state); at the start and not do the 
> statesToEnter.add() calls as per suggestion. The way it is written 
> above causes test 403c, 504 and 533 to fail. So the final 
> addDescendantStatesToEnter definition looks like this [1].
>
> Best regards,
> Zjnue
>
> [1]
> procedure addDescendantStatesToEnter(state,statesToEnter,statesForDefaultEntry, defaultHistoryContent):
>      statesToEnter.add(child)
>
>      if isCompoundState(state):
>          statesForDefaultEntry.add(state)
>          for s in getTargetStates(state.initial):
>             addDescendantStatesToEnter(s,statesToEnter,statesForDefaultEntry)
>             addAncestorStatesToEnter(s, state, statesToEnter, statesForDefaultEntry, defaultHistoryContent)
>      elif isParallelState(state):
>           for child in getChildStates(state):
>               if not statesToEnter.some(lambda s: isDescendant(s,child)):
>                  addDescendantStatesToEnter(child,statesToEnter,statesForDefaultEntry, defaultHistoryContent)

-- 
Jim Barnett
Genesys

Received on Tuesday, 1 April 2014 15:47:43 UTC