Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » allInstances()?
allInstances()? [message #1800619] Thu, 03 January 2019 17:43 Go to next message
jo ber is currently offline jo berFriend
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
MM!C1.allInstances()

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 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

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 #1800659 is a reply to message #1800627] Fri, 04 January 2019 16:46 Go to previous messageGo to next message
jo ber is currently offline jo berFriend
Messages: 92
Registered: August 2018
Member
Hi

As alternative to 'thisModule.resolveTemp', I've tried to use EMFTVM tracing metamodel
thisModule.traces.defaultSourceElements -> select(e | e.name = 'xxx') -> select(e | e.object.prop = yyy) 
			             -> first().sourceOf.targetElements -> select(e | e.name = 'zzz') -> first().object

Seems to fill my needs. However, I'm wondering whether I'm not misusing ATL?

Thank you and kind regards,
Re: allInstances()? [message #1800673 is a reply to message #1800659] Fri, 04 January 2019 22:05 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

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
Previous Topic:[EMFTVM] Multi-valued field
Next Topic:How to get a .xmi file from .xml?
Goto Forum:
  


Current Time: Sat Nov 11 08:20:25 GMT 2023

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

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

Back to the top