|Implementation of instance-of references [message #884514]
||Mon, 11 June 2012 08:25
Registered: February 2012
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!
The metamodel (in MinimalEcore syntax):
abstract interface NamedElement (
Network : NamedElement (
// network elements
ElementType : NamedElement (
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 08:39]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02139 seconds