|[ECore] How to reference fixed Ecore classes as well as model instances [message #659353]
||Sat, 12 March 2011 17:04
| Glenview Jeff
Registered: September 2010
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.)|
xClass: 0..* Containment=yes
xClass: EClass, xType
xField: 0..* Containment=yes
xType: 1 Containment =no
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?
[Updated on: Sat, 12 March 2011 17:05]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01797 seconds