Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] How to make a type cast?
[Acceleo] How to make a type cast? [message #1018839] Thu, 14 March 2013 10:58 Go to previous message
Iban Ayestaran is currently offline Iban Ayestaran
Messages: 58
Registered: September 2011
Member
Hi,

I am using Acceleo with a meta-model with some inherited classes. Imagine classes 'child1' and 'child2' inherit from 'parent'.

I want to do this:

[for (_par : Parent | aModel.eAllContents()->filter(Parent))]
    _par.parentattribute1 [comment write parent attributes of the class/]
    [if (_par.oclIsTypeOf(child1))]
	[(child1) _par;/]     [comment this does not work!!/]
        _par.child1attribute1 [comment write child1 attributes of the class/]
    [/if]
    [if (_par.oclIsTypeOf(child2))]
	[(child2) _par;/]     [comment this does not work!!/]
        _par.child2attribute1 [comment write child2 attributes of the class/]
    [/if]
[/for]


As far as I know, to be able to read an attribute defined in a child class I need to cast my object to be seen by acceleo as a child class, and I do not know how to do this. I tried this in different ways, for example the one above, but this is not accepted by acceleo.

Do you know how to do it?
 
Read Message
Read Message
Read Message
Read Message
Previous Topic:[Acceleo] Invalid attributes during template invocation
Next Topic:Xpand Workflow file
Goto Forum:
  


Current Time: Sun May 26 02:43:15 EDT 2013

Powered by FUDForum. Page generated in 0.01781 seconds