Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » How can I reuse the template from a super metaclass
How can I reuse the template from a super metaclass [message #1808717] Sat, 29 June 2019 19:08 Go to next message
Eclipse UserFriend
Let's say that there are two metaclasses: MetaClassA and MetaClassB. MetaClassB is a submetaclass of MetaclassA and MetaClassA is not abstract. Therefore it is possible to create an instance of MetaClassA which is not kind of MetaClassB.

In the Acceleo code there will be something like this (same module):

[template tmpl (anElement: MetaClassA)]

[/template]

[template tmpl (anElement: MetaClassB)]

[/template]


Is it possible to reuse tmpl of MetaClassA inside the tmpl of MetaClassB?

I know it's possible to separate the templates into modules and then use the extends . However, in my metamodel there are some cases with multiple inheritance, so this approach would fail.

I have thinked in only one solution: creating a template for MetaClassA (e.g., tmplAReusable) and then call it inside tmplB. For example:

[template tmplAReusable (anElement: MetaClassA)]
...
[/template]

[template tmpl(anElement: MetaClassA)]
[anElement.tmplAReusable() /]
[/template]

[template tmpl(anElement: MetaClassB)]
[anElement.tmplAReusable() /]
...
[/template]


Any Suggestions?
Thanks.
Re: How can I reuse the template from a super metaclass [message #1808720 is a reply to message #1808717] Sun, 30 June 2019 01:13 Go to previous messageGo to next message
Eclipse UserFriend
Hi

I can only recommend your solution.

Acceleo is based on MOFM2T 1.0. Once some enthusiasts appear to support a 1.1, rule re-use is an issue that might be addressed. For now, there is no OMG support team, and Acceleo is not under active development.

Regards

Ed Willink

[Updated on: Sun, 30 June 2019 04:10] by Moderator

Re: How can I reuse the template from a super metaclass [message #1808733 is a reply to message #1808720] Sun, 30 June 2019 09:58 Go to previous message
Eclipse UserFriend
Sure, Thank you for the information
Previous Topic:Comparison for upperbound is not working
Next Topic:[Acceleo] Circular dependencies
Goto Forum:
  


Current Time: Sat Jun 21 11:29:49 EDT 2025

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

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

Back to the top