| XPand et inheritance [message #537063] |
Tue, 01 June 2010 04:43  |
jeremie Messages: 233 Registered: April 2010 |
Senior Member |
|
|
Hi,
I have a problem to treat inheritance with XPand,
For example, I have this model :
class A {
private B : elementB;
}
interface B{}
classe C implements B {}
classe D implements B {}
classe E implements B {}
I will like to do specific treatment for each classes C D and E,
T XPand fille look like this :
«IMPORT model»;
«DEFINE a FOR A»
«EXPAND ... FOR this.elementB»
«ENDDEFINE»
I don't know what I have to write in the EXPAND line because this.elementB can be of type C, D or E..
we can imagine I have a file TreatC.xpt, TreatD.xpt or TreatE.xpt, to make a specific treatment for each type of element.
Thanks.
Jérémie
|
|
|
| Re: XPand et inheritance [message #537081 is a reply to message #537063] |
Tue, 01 June 2010 05:23   |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
Are classe C, classe D, classe E different types from your metamodel ?
If yes, Xpand supports polymorphism, so you just have to define 3 different templates, one for classe C type, one for classe D type, and one for classe E type.
One day I shall master M2T, but that day has yet to come...
|
|
|
|
|
| Re: XPand et inheritance [message #537100 is a reply to message #537063] |
Tue, 01 June 2010 06:45   |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
You don't need any "instanceof"
You can just do it that way :
RInteger, RBool, RFloat and RString have RDatatype for ESuper type.
| Quote: | «EXPAND tosql FOR RDatatype»
«DEFINE tosql FOR RInteger»INTEGER«ENDDEFINE»
«DEFINE tosql FOR RBool»BOOLEAN«ENDDEFINE»
«DEFINE tosql FOR RFloat»DOUBLE«ENDDEFINE»
«DEFINE tosql FOR RString»VARCHAR(40)«ENDDEFINE»
|
One day I shall master M2T, but that day has yet to come...
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01703 seconds