[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.m2m] Re: [ATL] Re-usable modules with metamodels as formal parameters?

Matthias Bohlen schreef:
Hi all,

Hi Matthias,


my metamodels have common subsets of metaclasses. For these metaclasses, I have fixed transformation rules. Is it possible to put these rules into a separate "rule library" module and use them from several other transformations?

The (lightweigth) solution for this is to use module superimposition. My use case is to start from a general "copy" transformation and then override a few rules to do something specific (i.e. "refinement").



Example:

Metamodels MA, MB and MC all share the same metaclass MClass with the same set of attributes. There are transformations that transform MA into MB or MB into MC.

So, I'd like to be able to write something like this:

module MClassLibrary (param1, param2);

create OUT: param2 from IN: param1;

-- Copy all MClasses from one model to the next
rule MClassToMClass {
    from mclassIn : param1!MClass
    to mclassOut : param2!MClass (
        name <- mclassIn.name
        ,someOtherAttribute = mclassIn.someOtherAttribute
    )
}

And then:

module TransformAtoB;
create OUT: MB from IN: MA;
uses MClassLibrary (MA, MB);
-- more rules that operate especially on MA go here.

As well as:

module TransformBtoC;
create OUT: MC from IN: MB;
uses MClassLibrary (MB, MC);
-- more rules that operate especially on MB go here.

Is this possible? How?

Superimposition cannot do *exactly* what you want. It can work for you, if it's possible to use the same meta-model and model names (IN, OUT, MB, MA, etc.). In this case, you can define a general transformation module with the common transformation rules already in there. Then, you define another transformation module with some specific rules (and perhaps additional models/meta-models), which you can "superimpose" on top of the general transformation module.


--
Dennis


Cheers, Matthias at andromda.org