Model-Driven Evolution of Software Architectures - Software and ...
Model-Driven Evolution of Software Architectures - Software and ...
Model-Driven Evolution of Software Architectures - Software and ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
5.5. GeneratingStateMachines 93<br />
rule MergedSimpleState {<br />
from s_in:UML!SimpleState (<br />
thisModule.mergedStates->includes(s_in))<br />
to s_out:UML!SimpleState(<br />
nameiterate(s; mss:Set(UML!StateVertex)=Set{} |<br />
if mss->exists(e|(e.mergeable(s)) then<br />
mss<br />
else<br />
mss->including(s)<br />
endif)<br />
;<br />
helper context UML!StateVertex def: mergeable(s:UML!StateVertex):<br />
Boolean =<br />
thisModule.unifiable(self.constraint,s.constraint) <strong>and</strong> self.name=s.<br />
name<br />
;<br />
helper def: unifiable(cset1:Set(UML!Constraint),cset2:Set(UML!<br />
Constraint)): Boolean =<br />
let sharedSVs:Set(UML!Attribute) = cset1->collect(c|c.stateVariable<br />
)->select(a|cset2->collect(c|c.stateVariable)->includes(a)) in<br />
sharedSVs->forAll(a|cset1->select(c|c.stateVariable=a)=<br />
cset2->select(c|c.stateVariable=a))<br />
;<br />
Listing 5.3:MergingSimpleStates<br />
MergingFlatStateMachines Inthisstepwemergetheflatstatemachines.<br />
Wemergeeveryset<strong>of</strong>stateswithunifiablestatevectors<strong>and</strong>atleastone<br />
identicalincomingtransition(interms<strong>of</strong>effectortrigger).<br />
Merging<strong>of</strong>statesisdonebytherule<strong>and</strong>helpersinListing5.3.Therule<br />
matchesallstatesselectedbythe mergedStateshelperthatiterativelyselectsoneSimpleStatefromeverygroup<strong>of</strong>equalSimpleStatesinthesource<br />
model. Acalltothe mergeablehelperresultsintruewhenthereceiving<br />
StateVertex<strong>and</strong>theparameterStateVertex1)(s)areunifiable,<strong>and</strong>2)have<br />
thesamename(i.e.,theincomingtransitionshadthesametriggeroreffect).<br />
The unifiablehelperevaluatestotruefortwosets<strong>of</strong>Constraints<br />
thatdonotspecifydifferentvaluesforthesamestatevariable,meaning<br />
thattheconstraintthatreferstoaparticularstatevariablethatisalso<br />
referredtointheotherset,isactuallyincludedinthatset.<br />
Transitionsarematchedbyanotherrule(notshown).TodiscardredundantTransitions,itonlymatchesoneTransition<strong>of</strong>theTransitionsbetween<br />
anytwosets<strong>of</strong>SimpleStatesthataremerged.