Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Use polymorphism with 2 xpand file
Use polymorphism with 2 xpand file [message #522712] Tue, 23 March 2010 17:23 Go to next message
Christophe is currently offline ChristopheFriend
Messages: 15
Registered: July 2009
Junior Member
Hi all,

How to use pollymorphism with the 2 distinct xpt file ? Thanks.

** Assumptions **
- A is a mother class
- B is a child class of A
- The code depending on B must be located in an separate .xpt file
- The code of A must be isolated (no reference to B templates)

The objective is to implement the following sample:

«DEFINE someOtherDefine FOR SomeMetaClass»
«EXPAND implClass FOREACH listOfAs»
«ENDDEFINE»

«DEFINE implClass FOR A»
// specific code for A
«ENDDEFINE»

«DEFINE implClass FOR B»
// specific code for B
«ENDDEFINE»


BR.
Re: Use polymorphism with 2 xpand file [message #522846 is a reply to message #522712] Wed, 24 March 2010 08:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello you can call another template in anothfile like this

«DEFINE implClass FOR A»
«EXPAND path::to::otherTemplateFile::otherDefinition FOR this»
«ENDDEFINE»


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 24 March 2010 08:23]

Report message to a moderator

Re: Use polymorphism with 2 xpand file [message #522853 is a reply to message #522846] Wed, 24 March 2010 08:50 Go to previous messageGo to next message
Christophe is currently offline ChristopheFriend
Messages: 15
Registered: July 2009
Junior Member
Thanks, but in your proposition, the following assumption is not respected :
"The code of A must be isolated (no reference to B templates)".

Regards.

Re: Use polymorphism with 2 xpand file [message #522859 is a reply to message #522712] Wed, 24 March 2010 08:58 Go to previous messageGo to next message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
Could you give us an example ?
I don't think I understand what you need.

in my current project, I use that, which seems to be what you need

			«FOREACH attributes() AS a-»
				private «EXPAND typeJava::tojava FOR a.type» «a.name»;
			«ENDFOREACH»


and in typejava file

«DEFINE tojava FOR Typedef»«EXPAND tojava FOR this.reftype»«ENDDEFINE»
«DEFINE tojava FOR GInteger»int«ENDDEFINE»
«DEFINE tojava FOR GBool»boolean«ENDDEFINE»
«DEFINE tojava FOR GFloat»float«ENDDEFINE»
«DEFINE tojava FOR GString»String«ENDDEFINE»


I just don't understand why what you wrote in the first example doesn't work (as long as both DEFINE ImplClass are in the same file).


One day I shall master M2T, but that day has yet to come...
Re: Use polymorphism with 2 xpand file [message #522863 is a reply to message #522859] Wed, 24 March 2010 09:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
why don't create a template for type A and another for B and a third template that does the switch?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Use polymorphism with 2 xpand file [message #522866 is a reply to message #522863] Wed, 24 March 2010 09:16 Go to previous message
Christophe is currently offline ChristopheFriend
Messages: 15
Registered: July 2009
Junior Member
Maxime,
I wish for instance add the following template without updating the typejava file and the current project.

«DEFINE tojava FOR GAnotherType»AnotherType«ENDDEFINE»

This new template should be in a new file (ex: MyComplexType.xpt)

Christian,
Good idea, it's probably the best solution to make a workaround
Previous Topic:SQL Beautifier ??
Next Topic:Additional Xpath Functions
Goto Forum:
  


Current Time: Tue Apr 23 07:10:39 GMT 2024

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

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

Back to the top