Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » derived classes
derived classes [message #23240] Tue, 13 March 2007 12:37 Go to next message
Eclipse UserFriend
Originally posted by: not.provided.info

how to access derived classes attributes through the parent class if all
derived classes are matched by parent class type? oclAsType() isn't
implemented, downcasting isn't possile?

from all: A!parent( parent.oclIsTypeOf( A!derived ) )
Re: derived classes [message #23241 is a reply to message #23240] Tue, 13 March 2007 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: not.provided.info

my code:

class Parent {}
class derivedA extends Parent {}
class derivedB extends Parent {
attribute b : Double;
}

classes[*] container : Parent;

classes->collect( class | thisModule.Do( class ) )

lazy rule Do {
from class : MM!derivedA
...
}

lazy rule Do {
from class : MM!derivedB
...
class.b fails with message MM!derivedA don't have b feature
}

why class.b fails, event then lazy rule Do is matched for the MM!derivedB?
[ATL] Re: derived classes [message #23322 is a reply to message #23241] Tue, 13 March 2007 14:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mikael.barbero.gmail.com

Dear Gediminas,

First, can you please stick with this newsgroup rules and prefix all of
your messages with [ATL] as their is more than one component in Eclipse
Modeling's M2M project.

Concerning your question, you cannot have multiple rules with the same
name. I suggest you re-writing (if possible) your rules not to have lazy
rules but matched (classical) rules. This way, you will be able to use
rule inheritance feature (which is not available for lazy rules, i think):

abstract rule Parent {
from i: MM!Parent
..
}

rule A extends Parent {
from i : MM!derivedA
..
}

rule B extends Parent {
from i : MM!derivedB
..
}

and don't forget to specify on your first this comment:
--@atlcompiler atl2006
and to checkout the atl2006 compiler's plug-in.

Best regards,
Mikael

Gediminas a écrit :
> my code:
>
> class Parent {}
> class derivedA extends Parent {}
> class derivedB extends Parent {
> attribute b : Double;
> }
>
> classes[*] container : Parent;
>
> classes->collect( class | thisModule.Do( class ) )
>
> lazy rule Do {
> from class : MM!derivedA
> ..
> }
>
> lazy rule Do {
> from class : MM!derivedB
> ..
> class.b fails with message MM!derivedA don't have b feature
> }
>
> why class.b fails, event then lazy rule Do is matched for the MM!derivedB?
>



--
Mikaël Barbero - PhD Candidate
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssinière
44322 Nantes Cedex 3 - France
tel. +33 2 51 12 58 08 /\ cell.+33 6 07 63 19 00
email: Mikael.Barbero@{gmail.com, univ-nantes.fr}
http://www.sciences.univ-nantes.fr/lina/atl/
Re: [ATL] Re: derived classes [message #23407 is a reply to message #23322] Tue, 13 March 2007 22:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: not.provided.info

no problem, I just wonder, why there is no ATL dedicated newsgroup as it
was in yahoogroups time? It seems to me, that one mix of everything isn't
the best decision.

I'm not sure, if it's possible to drop lazy rules. The question still
remaines - why lazy rules for derived types pass parent type? derived type
is stricker than parent's, so check (with/without oclIsTypeOf) of parent
type for derived one should fail

Currently I don't use ATL2006 version - does it fully support pre ATL2006
features? also, I had big dissapointments by trying to check out ATL CVS
version, so I prefer to use ATL bundle "releases"
Re: [ATL] Re: derived classes [message #23536 is a reply to message #23322] Fri, 16 March 2007 13:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: not.provided.info

so there is no solution with lazy rules? it's not possible (in a timely
manner) to rewrite transformation to use matched rules :-/
Re: [ATL] Re: derived classes [message #23579 is a reply to message #23536] Fri, 16 March 2007 14:53 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> so there is no solution with lazy rules? it's not possible (in a
> timely manner) to rewrite transformation to use matched rules :-/

The current implementation of lazy rules requires you to explicitly call
them: they are not actually matched.
Therefore, you need to make sure to call the appropriate rule.

One solution, in your case, is to use an if expression in the body of
the collect iterator:

lazy rule DoA {
from class : MM!derivedA
....
}

lazy rule DoB {
from class : MM!derivedB
....
}

classes->collect( class |
if class.oclIsKindOf(mm!derivedA) then
thisModule.DoA( class )
else -- if class.oclIsKindOf(MM!derivedB) then
thisModule.DoB( class )
endif
)


> Currently I don't use ATL2006 version - does it fully support pre
> ATL2006 features?

ATL 2006 supports most of ATL 2004 (i.e., "pre ATL2006" as you call it)
features, with the notable exception of refining mode, which does not
work yet.

Note however, that you can choose which version of ATL to use for each
of your ATL programs. Thus, if you have one program requiring refining
mode, you can use ATL 2004 with it, and ATL 2006 with all other programs.

You can find for more information about ATL 2006 on the wiki:
http://wiki.eclipse.org/index.php/ATL_2006

> I had big dissapointments by trying to check out ATL CVS version, so I
> prefer to use ATL bundle "releases"

The latest download available from http://www.eclipse.org/m2m/atl/download/
includes the ATL 2006 compiler.


Regards,

Frédéric Jouault
Re: [ATL] Re: derived classes [message #23622 is a reply to message #23579] Fri, 16 March 2007 15:27 Go to previous message
Eclipse UserFriend
Originally posted by: not.provided.info

thanks, Frederic, your solution is a shorter than mine, so use your's :)
Previous Topic:How to distinguish several in- and out-models
Next Topic:UML1.3 To IF Transformation
Goto Forum:
  


Current Time: Tue Mar 19 04:00:58 GMT 2024

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

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

Back to the top