Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » 1:m mappings / avoid traces
1:m mappings / avoid traces [message #875181] Tue, 22 May 2012 09:16 Go to next message
Eclipse UserFriend
Hello,

this is something I've been wondering over for a long time, and never
found a satisfying solution.

Suppose the source model has two objects A, B referencing the same
object of class C. The mapping shall be done like this:

mapping A::mapA() : P {
myKid := self.C.map mapC();
}

mapping B::mapB() : Q {
myKid := self.C.map mapC();
}

mapping C::mapC() : R {
-- I want this to be executed each(!) time
}

Now, as far as I understand it, when mapB() is called, mapC() is not
being executed. Instead R is retrieved from the traces. Now how can I
avoid that? How can I force a new object to be created, using the same
syntax. So far I have resolved to map R now using a mapping operation,
but to write a helper function that explicitly instantiates it. But that
requires a different invocation and appears awkward to me. Is there a
better way to handle this?

Thanks
Marius
Re: 1:m mappings / avoid traces [message #875189 is a reply to message #875181] Tue, 22 May 2012 09:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7098
Registered: July 2009
Senior Member
Hi

My interpretation is that each output is related to a ?ordered? set of
one or more input objects, and so when a 'new' output object is
required, any existing object derived from the same set of objects is
re-used.

To suppress this optimisation increase the dependency to add an
additional disambiguating object as a mapping parameter, and give that
disambiguator a different value for each different output object.

[This is my thinking backed by empirical discovery. It makes sense but
I'm not convinced that it;'s in the specification.]

Regards

Ed Willink

On 22/05/2012 10:16, Marius Gröger wrote:
> Hello,
>
> this is something I've been wondering over for a long time, and never
> found a satisfying solution.
>
> Suppose the source model has two objects A, B referencing the same
> object of class C. The mapping shall be done like this:
>
> mapping A::mapA() : P {
> myKid := self.C.map mapC();
> }
>
> mapping B::mapB() : Q {
> myKid := self.C.map mapC();
> }
>
> mapping C::mapC() : R {
> -- I want this to be executed each(!) time
> }
>
> Now, as far as I understand it, when mapB() is called, mapC() is not
> being executed. Instead R is retrieved from the traces. Now how can I
> avoid that? How can I force a new object to be created, using the same
> syntax. So far I have resolved to map R now using a mapping operation,
> but to write a helper function that explicitly instantiates it. But that
> requires a different invocation and appears awkward to me. Is there a
> better way to handle this?
>
> Thanks
> Marius
Re: 1:m mappings / avoid traces [message #876371 is a reply to message #875189] Thu, 24 May 2012 13:23 Go to previous message
Eclipse UserFriend
On 22.05.2012 11:33, Ed Willink wrote:
> My interpretation is that each output is related to a ?ordered? set of
> one or more input objects, and so when a 'new' output object is
> required, any existing object derived from the same set of objects is
> re-used.
>
> To suppress this optimisation increase the dependency to add an
> additional disambiguating object as a mapping parameter, and give that
> disambiguator a different value for each different output object.

Thanks, your answer got me thinking (never hurts) - actually, by itself,
this "optimization" isn't wrong: the same input gets the same output.
What's wrong is probably my usage of the output object. I want to add a
single output object in two containers, which won't work for obvious
reasons. But as my output model is a set of XSDs loaded dynamically
using XSDEcoreBuilder, I probably could patch the Ecore model after
loading to remove the containment flags. Everything but pretty, but it
may work.

Marius
Previous Topic:Transformations between enums in QVTo
Next Topic:QVT analyser
Goto Forum:
  


Current Time: Mon Apr 19 04:32:06 GMT 2021

Powered by FUDForum. Page generated in 0.01433 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top