Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Composite Class
Composite Class [message #37346] Sat, 12 May 2007 00:58 Go to next message
Eclipse UserFriend
Originally posted by: mpitanga.gmail.com

Hi,

I have the following situation:

Class A {
method1,
method2
}

Class B {
method3,
method4
}

and I need to create a third Class, for example:

Class C {
method1, // copy from Class A
method2, // copy from Class A
method3, // copy from Class B
method4 // copy from Class B
}

ps. Class A and Class B belong to the same model.

In the end of the transformation process my model will have 3 classes

Class A {
method1,
method2
}

Class B {
method3,
method4
}

Class C {
method1, // copy from Class A
method2, // copy from Class A
method3, // copy from Class B
method4 // copy from Class C
}

has someone an example?

Thanks
[ATL] Re: Composite Class [message #37380 is a reply to message #37346] Sat, 12 May 2007 10:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mpitanga.gmail.com

"Marcelo Alves" <mpitanga@gmail.com> wrote in message
news:f233ea$j4a$1@build.eclipse.org...
> Hi,
>
> I have the following situation:
>
> Class A {
> method1,
> method2
> }
>
> Class B {
> method3,
> method4
> }
>
> and I need to create a third Class, for example:
>
> Class C {
> method1, // copy from Class A
> method2, // copy from Class A
> method3, // copy from Class B
> method4 // copy from Class B
> }
>
> ps. Class A and Class B belong to the same model.
>
> In the end of the transformation process my model will have 3 classes
>
> Class A {
> method1,
> method2
> }
>
> Class B {
> method3,
> method4
> }
>
> Class C {
> method1, // copy from Class A
> method2, // copy from Class A
> method3, // copy from Class B
> method4 // copy from Class C
> }
>
> has someone an example?
>
> Thanks
>
>
Re: [ATL] Re: Composite Class [message #37482 is a reply to message #37380] Mon, 14 May 2007 10:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rchevrel.sodius.com

I Marcello,

I'm not sure to completely understand what you want to do but you can try:

-----------------------------------
-- to keep the existing classes
rule ClassToClass {
from
in_cls : MMa!Class
to
out_cls : MMa!Class (
methods <- in_cls.methods...
)
}
-----------------------------------
-- to create the composites classes
rule ClassToComposite {
from
in_cls1 : MMa!Class,
in_cls2 : MMa:Class (
cls1 <> cls2
)
to
out_comp_cls : MMa!Class (
methods <- in_cls1.methods->union(in_cls2.methods)...
)
}
-----------------------------------
rule MethodToMethod {
....
}
-----------------------------------

It can work only if MMA!Class.methods is not a container feature
(because an element cannot be contained by two element).
If it is a container feature, you have to duplicate the "method"
(probably with a CalledRule). Send a mail more precise if you have some
problems.

Cordially,

*Régis CHEVREL* <mailto:rchevrel@sodius.com>


SODIUS*
*6, rue Cornouaille
44319 Nantes - France

Phone: +33 (0)2 28 23 54 34

***www.mdworkbench.com* <http://www.mdworkbench.com/>* *
Draw more value from your model
Re: [ATL] Re: Composite Class [message #37515 is a reply to message #37482] Mon, 14 May 2007 12:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mpitanga.gmail.com

Hi Régis,

Thank you for reply

You said:
"It can work only if MMA!Class.methods is not a container feature (because
an element cannot be contained by two element).
If it is a container feature, you have to duplicate the "method" (probably
with a CalledRule). "

and this is my problem.

is possible duplicate a container feature and to point for another class?

Thanks,

Marcelo
Re: [ATL] Re: Composite Class [message #37652 is a reply to message #37515] Tue, 15 May 2007 05:12 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,

> You said:
> "It can work only if MMA!Class.methods is not a container feature
> (because an element cannot be contained by two element).
> If it is a container feature, you have to duplicate the "method"
> (probably with a CalledRule). "
>
> and this is my problem.
>
> is possible duplicate a container feature and to point for another class?

As Régis suggested, you may use a called rule. However, I would rather
advise to stick with declarative style, and use a lazy rule ;-).

You only need to add the "lazy" keyword to the beginning of the rule
that transformed the contained elements (i.e., rule Method2Method in
your case), and call the lazy rule by writing something like:

method_list->collect(e | thisModule.Method2Method(e))

where method_list is the list of methods:

- in_cls.methods in rule Class2Class
- in_cls1.methods->union(in_cls2.methods) in rule Class2Composite


Regards,

Frédéric Jouault
Re: [ATL] Re: Composite Class [message #38619 is a reply to message #37652] Wed, 16 May 2007 14:00 Go to previous message
Eclipse UserFriend
Originally posted by: mpitanga.gmail.com

Hi Frédéric,

The one that you suggested worked fine.

Thank you very much also for the Régis.

Regards,

Marcelo
Previous Topic:[ATL] how to find an already generated element in non-declarative rules ?
Next Topic:[ATL] Libraries and Prequesites to launch ATL transformations programaticallly from Java
Goto Forum:
  


Current Time: Mon Jan 25 15:08:13 GMT 2021

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

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

Back to the top