Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Ecore Tools » [ECore] How to reference fixed Ecore classes as well as model instances
[ECore] How to reference fixed Ecore classes as well as model instances [message #659353] Sat, 12 March 2011 12:04 Go to next message
Glenview Jeff is currently offline Glenview Jeff
Messages: 79
Registered: September 2010
Member
I ran into what I believe may be a limitation of Ecore. I want to be able to define a metamodel with fixed set of datatypes as well as a reference datatype that references existing classes. My metamodel would look like this ideally (hopefully my pseudocode is readable.)

Metamodel:
  RootEClass: EClass
    xClass: 0..* Containment=yes
  
  xClass: EClass, xType
    xField: 0..* Containment=yes

  xField: EClass
    xType: 1 Containment =no

  xType: EClass

  StringType: xType
  IntType: xType


The problem with the above strategy is that in the model, I can't set a field's type to StringType or IntType since they haven't been instantiated in the model. I can only set a field type to whatever xClasses have been instantiated in the model.

I of course could do it as they do in the xpand sample project, where you create types in your model, but I think this is a poor design choice. I think that the data types should be fixed in the meta-model, not in the model.

The other way I thought to do it is to have an enumeration to refer to the fixed types, int, bool, etc., and one special enumeration that's called a reference. Then I'd have to have a separate field in the xType that's actually a reference. This is also quite ugly.

It is possible to accomplish this in Jetbrains MPS (see this tutorial.) Is there a similar mechanism I might be missing available in Ecore?

Thanks!
Jeff

[Updated on: Sat, 12 March 2011 12:05]

Report message to a moderator

Re: [ECore] How to reference fixed Ecore classes as well as model instances [message #727419 is a reply to message #659353] Wed, 21 September 2011 05:04 Go to previous messageGo to next message
Peter Saunders is currently offline Peter Saunders
Messages: 30
Registered: July 2009
Member
glenviewjeff wrote on Sat, 12 March 2011 12:04
I ran into what I believe may be a limitation of Ecore. I want to be able to define a metamodel with fixed set of datatypes as well as a reference datatype that references existing classes. My metamodel would look like this ideally (hopefully my pseudocode is readable.)

Metamodel:
  RootEClass: EClass
    xClass: 0..* Containment=yes
  
  xClass: EClass, xType
    xField: 0..* Containment=yes

  xField: EClass
    xType: 1 Containment =no

  xType: EClass

  StringType: xType
  IntType: xType


The problem with the above strategy is that in the model, I can't set a field's type to StringType or IntType since they haven't been instantiated in the model. I can only set a field type to whatever xClasses have been instantiated in the model


I'm looking at a similar problem at present. As an example, consider a model that describes books and colors. Each book has exactly one color. Some common colors must be pre-defined ("red", "blue", ...), but some colors will be defined by the user.

Is is possible to use ECore to specify a class that will be instantiated at the time that the root class is instantiated? If not, what is the best way to define this sort of model using ECore?

Peter
Re: [ECore] How to reference fixed Ecore classes as well as model instances [message #761425 is a reply to message #727419] Tue, 06 December 2011 08:14 Go to previous messageGo to next message
Algar fr is currently offline Algar fr
Messages: 19
Registered: December 2011
Junior Member
Any solutions to this problem?

It seems exactly the same as the problem I have commented in this other post:
eclipse.org/forums/index.php/t/263531/

I will really appreciate any help about it.

PS: Sorry for the relative link. I cannot use URLs as I haven't reach 5 messages... Sad
Re: [ECore] How to reference fixed Ecore classes as well as model instances [message #764474 is a reply to message #761425] Mon, 12 December 2011 04:00 Go to previous message
Algar fr is currently offline Algar fr
Messages: 19
Registered: December 2011
Junior Member
No Message Body
Previous Topic:Is it possible to reference eClasses from xmi instances?
Next Topic:Extension Point Modeling Framework
Goto Forum:
  


Current Time: Thu Aug 21 12:16:59 EDT 2014

Powered by FUDForum. Page generated in 0.02427 seconds