allInstances()? [message #1800619] |
Thu, 03 January 2019 17:43 |
jo ber Messages: 92 Registered: August 2018 |
Member |
|
|
Hi
How can I access from a rule B to all the instances that have been previously created by a transformation rule A? In this case, using
returns an empty sequence...
Thank you and kind regards.
[Updated on: Thu, 03 January 2019 17:45] Report message to a moderator
|
|
|
Re: allInstances()? [message #1800627 is a reply to message #1800619] |
Thu, 03 January 2019 22:25 |
|
In ATL, you shouldn't directly access instances created by the transformation. Where possible, this is even prohibited by the ATL runtime, to prevent your transformation code relying on one of ATL's VM's implementation details (rule execution strategy in this case, which differs slightly between VMs).
Instead, you may access the input elements of rule A instead, and rely on ATL's implicit tracing mechanism to translate them to the corresponding output elements. The source-to-target element resolution is triggered automatically on the '<-' binding operator, but can also be triggered manually using the 'thisModule.resolveTemp()' operation on the source element.
Cheers,
Dennis
|
|
|
|
Re: allInstances()? [message #1800673 is a reply to message #1800659] |
Fri, 04 January 2019 22:05 |
|
You're not misusing ATL, but your code is not very efficient for larger input models. 'thisModule.resolveTemp(source, targetName)' will give you the target element directly. As a sidenote, the EMFTVM Trace metamodel also has some EOperations (e.g. 'TraceLinkSet::getDefaultSourceElement(source)'), which offer performance-optimised access to trace elements: instead of iterating through ELists, the EOperations look up values directly in internal HashMaps. 'thisModule.resolveTemp()' also uses this optimised implementation.
I suppose the easiest and most performant way to use the trace model is via the built-in helper methods.
Cheers,
Dennis
|
|
|
Powered by
FUDForum. Page generated in 0.01742 seconds