derived classes [message #23240] |
Tue, 13 March 2007 08:37  |
Eclipse User |
|
|
|
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 ) )
|
|
|
|
[ATL] Re: derived classes [message #23322 is a reply to message #23241] |
Tue, 13 March 2007 10:05   |
Eclipse User |
|
|
|
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 #23579 is a reply to message #23536] |
Fri, 16 March 2007 10:53   |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03575 seconds