Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Unique Called Rules
[ATL] Unique Called Rules [message #73101] Tue, 22 January 2008 23:42 Go to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

When rules elements in an input model are matched in ATL, they are only
matched once, but when a called rule is called more than once, it can
generate more than one result.

Is there a way to use a called (lazy) rule such that, if the rule has
already been called on a given input, return the previously created
object, otherwise create a new one?

The reason I ask is because I need to write a rule that matches Strings,
and for each unique string, create a target element.

cheers,
ian
Re: [ATL] Unique Called Rules [message #73443 is a reply to message #73101] Sat, 26 January 2008 22:17 Go to previous messageGo to next message
Juancho  is currently offline Juancho Friend
Messages: 17
Registered: July 2009
Junior Member
Hi Ian,
AFAIK, you can use an UNIQUE lazy rule to that end.
For instance, given the following rule:

unique lazy rule A2X {
from
a : SourceMM!A

to
x : TargetMM!X
}

It will create a new X object each time you invoke it on a "new" A
object whilst if you invoke it with an already used A object, it will
return the previously created X object.

Hope this helps.
Juancho


Ian Bull escribió:
> When rules elements in an input model are matched in ATL, they are only
> matched once, but when a called rule is called more than once, it can
> generate more than one result.
>
> Is there a way to use a called (lazy) rule such that, if the rule has
> already been called on a given input, return the previously created
> object, otherwise create a new one?
>
> The reason I ask is because I need to write a rule that matches Strings,
> and for each unique string, create a target element.
>
> cheers,
> ian
Re: [ATL] Unique Called Rules [message #73460 is a reply to message #73443] Sun, 27 January 2008 05:25 Go to previous message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

THANK-YOU SO MUCH!

I kept thinking that unique was associated with the calling of the
rule... This works perfectly!

Thanks again Juancho,

cheers,
ian

Juan M. Vara wrote:
> Hi Ian,
> AFAIK, you can use an UNIQUE lazy rule to that end.
> For instance, given the following rule:
>
> unique lazy rule A2X {
> from
> a : SourceMM!A
>
> to
> x : TargetMM!X
> }
>
> It will create a new X object each time you invoke it on a "new" A
> object whilst if you invoke it with an already used A object, it will
> return the previously created X object.
>
> Hope this helps.
> Juancho
>
>
> Ian Bull escribió:
>> When rules elements in an input model are matched in ATL, they are
>> only matched once, but when a called rule is called more than once, it
>> can generate more than one result.
>>
>> Is there a way to use a called (lazy) rule such that, if the rule has
>> already been called on a given input, return the previously created
>> object, otherwise create a new one?
>>
>> The reason I ask is because I need to write a rule that matches
>> Strings, and for each unique string, create a target element.
>>
>> cheers,
>> ian
>
Previous Topic:Diagram from models in "Families2Persons"
Next Topic:problem with programmatically transformation of multiple-file models
Goto Forum:
  


Current Time: Sun Apr 11 01:39:15 GMT 2021

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

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

Back to the top