|
Re: Syntax for use of ecore types within HUTN [message #879135 is a reply to message #878747] |
Wed, 30 May 2012 15:27 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Chris,
I'm not quite clear on what you'd like to achieve, because EBoolean#true isn't an instance of EClassifier. (In fact, I'm pretty sure EBoolean#true isn't an instance of anything in Ecore: "true" is just a string that EcoreFactory recognises and uses to create a copy of java.lang.Boolean.TRUE).
Do you want to be able to reference an EClassifier (i.e. any instance of EClass or EDataType) from ThingWrapper? If so, then the following should do the trick:
@Spec {
metamodel "ThingWrappers" {
nsUri: "ThingWrappers"
}
metamodel "Ecore" {
nsUri: "http://www.eclipse.org/emf/2002/Ecore"
}
}
ThingWrappers {
ThingWrapper {
thing: EClass "Foo" {}
}
}
If you'd like to be able to wrap any model element, then you'd need to set the type of the thing reference to be EObject. If you'd like to be able to wrap any primitive, than we may need to do some further investigation, as I'm pretty sure Ecore doesn't support this natively.
Hope this helps,
Louis.
|
|
|
|
Re: Syntax for use of ecore types within HUTN [message #880964 is a reply to message #879264] |
Sun, 03 June 2012 14:03 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Chris,
Thanks a lot for the clarification; I think that I understand now.
Unfortunately, I'm almost certain that EMF doesn't have an equivalent of the "thing" type. In fact, I think that primitive and model element types are disjoint in Ecore. One possible way to approach this would be to have a slightly less elegant metamodel, that provides separate wrappers for the primitives and for model elements:
class BooleanWrapper {
attr Boolean[1] value;
}
class IntegerWrapper {
attr Integer[1] value;
}
// etc, for other primitive values
class ThingWrapper {
val EObject[1] thing;
}
With this metamodel, the HUTN would be as follows:
@Spec {
<blah>
}
ThingWrappers {
ThingWrapper "TW1" {
thing: BooleanWrapper { value: true }
}
ThingWrapper "TW2" {
thing: BoxOfChocolates "Chocs" {
name: "Milk Chocolates"
}
}
}
I hope this (slightly clunky) solution will work for you. If not, then we should perhaps ask for some help on the EMF forum.
Cheers,
Louis.
|
|
|
Powered by
FUDForum. Page generated in 0.04529 seconds