Hi,
I have a problem with my current modeling task:
I want to model an instance-of reference in Ecore. I have created a metamodel for description of a kind of networks:
- EClass "Network": holds all element types, elements and connections
- EClass "ElementType": defines a possible network element and its ports
- EClass "Element": instance-of "ElementType", one concrete network element
- EClass "ConnectionPort": a port of an element which is used by the "Connection" to connect to elements
- EClass "Connection": connects two connection ports
Each "ElementType" declaration contains a definition of the element's connection ports. As "Element" is an instance of "ElementType" it holds copies of the connection ports defined by its type.
Currently I simply copy (EcoreUtil.copyAll) the connection ports from "ElementType" to "Element" on first access to the getInPorts()/getOutPorts() method of "Element". This has many issues as unresolved proxies and duplicate "ConnectionPort" objects.
Do you have an idea of how I could do this in a better way?
Thank you very much for your help!
Best regards,
Stefan Wülfrath
The metamodel (in MinimalEcore syntax):
abstract interface NamedElement (
name EString
)
Network : NamedElement (
// types
elementTypes ElementType*
// network elements
elements Element*
connections Connection*
)
ElementType : NamedElement (
inPorts ConnectionPort*
outPorts ConnectionPort*
)
Element : NamedElement (
~elementType ElementType // models the instance-of reference
inPorts ConnectionPort* // defined by elementType, should be copied
outPorts ConnectionPort* // defined by elementType, should be copied
)
ConnectionPort : NamedElement (
~incomingConnections Connection* <> Connection.target
~outgoingConnections Connection* <> Connection.origin
)
Connection : NamedElement (
~origin ConnectionPort <> ConnectionPort.outgoingConnections
~target ConnectionPort <> ConnectionPort.incomingConnections
)
[Updated on: Mon, 11 June 2012 04:39] by Moderator