[ATL]2 target objects from one source object [message #86978] |
Wed, 23 July 2008 16:31  |
Eclipse User |
|
|
|
I had 2 rules like those:
rule A {
from
c_in: S:class
to
c_out: O:class (
c_out.elements<-c_in.properties
)
}
--
rule B {
from
p_in: S:property
to
p_out: O:field (
...
)
}
And ATL did that awesome magic, it knew that each property on
c_in.properties was mapped to a O:field, and populated the c_out.elements
with them.
When I try to improve rule B to generate 2 objects from each property, an
odd thing happens: ATL adds only the first generated element:
rule B {
from
p_in: S:property
to
p_out: O:field (
...
),
g_out: O:method (
...
)
}
--result: c_out.elements will have only O:field
rule B {
from
p_in: S:property
to
g_out: O:method (
...
),
p_out: O:field (
...
)
}
--result: c_out.elements will have only O:method
I want to have both elements together. I still can use imperative code to
solve this, but I would like to understand how it works, if it's the first
elements that's the official one, or if there is a better way to do that
in declarative way.
What would happen if instead of 2 objects, I use the iterative target
pattern element ? it will associate the first element, all elements or no
element at all?
my ATL version is 2.0, eclipse 3.3 (going to upgrade soon)
Thanks
|
|
|
|
Re: [ATL]2 target objects from one source object [message #87052 is a reply to message #87008] |
Thu, 24 July 2008 07:39  |
Eclipse User |
|
|
|
Originally posted by: Hugo.Bruneliere.univ-nantes.fr
Hi Alexandre,
Alexandre Torres a écrit :
>
> Solved with resolveTemp:
>
> --p_out union g_out
>
> rule A {
> from c_in: S:class
> to
> c_out: O:class (
> c_out.elements<-c_in.properties<-collect(p|resolveTemp(p,'p_out'))
> <-union(c_in.properties<-collect(p|resolveTemp(p,'g_out')))
> )
> }
The above expression, which is a bit more simple, should also give the
same result:
c_out.elements <- c_in.properties
<-union(c_in.properties<-collect(p|resolveTemp(p,'g_out')))
Best regards,
Hugo
> rule B {
> from p_in: S:property
> to
> p_out: O:field (
> ...
> ),
> g_out: O:method (
> ...
> )
> }
>
--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod (INRIA & EMN)
University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: hugo.bruneliere@inria.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
|
|
|
Powered by
FUDForum. Page generated in 0.05831 seconds