| Transformations between enums in QVTo [message #874933] |
Mon, 21 May 2012 16:28  |
n_uu_b Missing name Messages: 5 Registered: August 2011 |
Junior Member |
|
|
Hi,
I have a basic doubt about how can I make transformations between Enumerations,
e.g,
my source metamodel has a enum A with literals "a1" and "a2" and my target has a enum B with literals "b1" and "b2".
mapping A::A2B() : B{
B::b1 := A::a1; //It doesnt work
B2 := self.a2; //And it also doesnt work
}
So, how can I make this transformation correctly?
Thanks.
|
|
|
|
| Re: Transformations between enums in QVTo [message #875167 is a reply to message #874933] |
Tue, 22 May 2012 05:03   |
|
On 21.05.2012 22:28, n_uu_b Mising name wrote:
> I have a basic doubt about how can I make transformations between
> Enumerations, e.g, my source metamodel has a enum A with literals "a1"
> and "a2" and my target has a enum B with literals "b1" and "b2".
query SOURCE::A::toExt() : TARGET::B
{
return switch {
case (self = SOURCE::A::a1) TARGET::B::b1;
case (self = SOURCE::A::a2) TARGET::B::b2;
else assert error (false) with log("Illegal enum value");
}
}
That's how I usually do it. In your mapping you can then just type
dstEnumAttrib := self.srcEnumAttrib.toExt();
I'm sure the "assert error" thing can be optimized, but I don't know how
and it works that way for me.
Regards
Marius
|
|
|
|
Powered by
FUDForum. Page generated in 0.01498 seconds