|
Re: [XCORE] How to refer to a particular attribute [message #1268565 is a reply to message #1268406] |
Mon, 10 March 2014 17:22 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Simone,
Comments below.
On 10/03/2014 2:15 PM, Simone Di Cola wrote:
> Hi all, having the model below, I'd like to know if there is a way to
> refer from the class ComputationUnit to the array of elements defined
> in the abstract class Component.
>
> abstract class Component{
> String name
> contains Comment comment
> contains Contract contract
> contains DataElement[0..*] dataElements
> contains Service[1..*] services
> }
>
> class AtomicComponent extends Component{
> contains ComputationUnit computationUnit
> }
>
> class ComputationUnit{
> contains Method[1..*] methods
> }
>
> Basically, what I would like to do is to have a method lie
> getDataElement() inside the class ComputationUnit.
Yes, in general you can define operations with bodies (that use Xbase
syntax) and those bodies can refer to things in the model. In this
case, you've not defined an inverse reference for
AtomicComponent.computationUnit so you'd have to navigate from the
CompilationUnit to its container via EObject.eContainer() and cast it.
Probably nicer is to define a "container" reference in CompilationUnit
to access the containing AtomicComponent and from that you can of course
access all the features of a Component...
>
> Thanks
> Simone
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04140 seconds