Skip to main content



      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 13:23 Go to next message
Eclipse UserFriend
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 04:23 Go to previous messageGo to next message
Eclipse UserFriend
Hello you can call another template in anothfile like this

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

[Updated on: Wed, 24 March 2010 04:23] by Moderator

Re: Use polymorphism with 2 xpand file [message #522853 is a reply to message #522846] Wed, 24 March 2010 04:50 Go to previous messageGo to next message
Eclipse UserFriend
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 04:58 Go to previous messageGo to next message
Eclipse UserFriend
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).
Re: Use polymorphism with 2 xpand file [message #522863 is a reply to message #522859] Wed, 24 March 2010 05:08 Go to previous messageGo to next message
Eclipse UserFriend
why don't create a template for type A and another for B and a third template that does the switch?
Re: Use polymorphism with 2 xpand file [message #522866 is a reply to message #522863] Wed, 24 March 2010 05:16 Go to previous message
Eclipse UserFriend
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: Sat Jul 05 03:36:52 EDT 2025

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

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

Back to the top