|
Re: [ATL] Lazy rules and multiple instantiations [message #560077 is a reply to message #560036] |
Tue, 21 September 2010 07:05 |
Sylvain EVEILLARD Messages: 556 Registered: July 2009 |
Senior Member |
|
|
Your lazy rule only returns the first element.
So when you call that rule (->collect(a | thisModule.r2(a))), this returns the Data aliased s and only that.
Still, the data t and the flow are created but not affected so are placed at the root of the resulting model.
To solve this you can either use a called rule to specify what it should return :
rule r2(a : A!Class){
to
s: B!Data (),
t: B!Data (),
flow: B!SequenceFlow (
fSource<-s,
fTarget<-t
)
do{
--here you specify what the rule must return :
Sequence{s,t,flow};
}
} You'll lose the "unique" behavior though.
You can also use three unique lazy rules instead of just one :
rule r1 {
from
a : A!Model
to
m: B!Pool (
packagedElement<-A!Class.allInstances()
->collect(a |
let dataS : B!Data = thisModule.dataS(a) in
let dataT : B!Data = thisModule.dataT(a) in
let flow : B!SequenceFlow = thisModule.flow(a,dataS,dataT) in
Sequence{dataS,dataT,flow}
)
)
}
unique lazy rule dataS {
from
a : A!Class
to
s: B!Data ()
}
unique lazy rule dataT {
from
a : A!Class
to
t: B!Data ()
}
unique lazy rule flow {
from
a : A!Class, s : B!Data, t : B!Data
to
flow: B!SequenceFlow (
fSource<-s,
fTarget<-t
)
}
[Updated on: Tue, 21 September 2010 07:07] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04080 seconds