Model composition where instance of class is used multiple times

178 Views Asked by At

I want to model the following scenario:

  • A message a consists of one or more base types.
  • Base types are uint8 .. uint64 and int8 .. int64.
  • A message can also contain other messages.

Example:

Message position

  • uint8 x
  • uint8 y

Message movement

  • position start
  • position end
  • uint8 speed

This is what i modeled in Sirius so far Sirius model

The issue here is that I cannot link the message position twice to the message movement. Can you please provide a approach of modelling this problem?

1

There are 1 best solutions below

0
On BEST ANSWER

Your modelization is lacking one "layer" to represent your "message type" / "message instance" structure.

I think what you need to do is something a bit like this:

  • Class MessageType with a containment towards BaseType (which IMO should be renamed something like MessageDataType)
  • Class MessageInstance with a containment towards itself and a reference to a MessageType.

Then you end user must first create a MessageType instance, called "position" and a second one called "movement". Then create three MessageInstance instances, two pointing towards MessageType "movement" and one containing the first two MessageInstance instances.

I would also advise seriously thinking about how you want to name your concepts, because there is a potential confusion between an Ecore instance of one of your EClass and the fact that you are effectively modeling a type/instance structure.