Re: test for default history content

Jim Barnett <[email protected]>
Newsgroups gmane.comp.web.voice
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.