Pergunta

I have an EMF model like the next one:

HardwareVerification -1-*-> Driver 
HardwareVerification -0-*-> Environment
Environment -1-1-> Driver

Every time I create a instance of the EMF model I have to create a Driver in the environment and, another in the HardwareVerification, but what I need is to have the same Driver in both places.

For example:

h1 -> driver 1
h1 -> env1
env1 -> driver1

My question is: How should I model this? * I read that to manage links in EMF you can use another EClass with the source and target attribute.

Foi útil?

Solução

EReferences can be modeled as containment or non containment references. If you use non containment references, then you can refer to the same object that is contained in the model somewhere else.

Assuming that the Environment "owns" the driver, then that would be the containment reference. And the HardwareVerification would only "use" the driver, then that would be the non containment reference. a textual "UML" diagram could look like this (the < x > denotes the containment and the <> the non containment reference.

env1 <x>-----> driver1
                        ^
                        |
h1 <>--------------

Outras dicas

I believe the link you are talking about is the EReference.

When you adding an EReference to an EClass in ecore file, you can specify the cardinality by using the Lower Bound and Upper Bound property of the EReference.

In your case, you can set LowerBound = 1, UpperBound = -1 (infinite) to represent -1-*->

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top