Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EReference and primitive types
EReference and primitive types [message #429936] Wed, 06 May 2009 21:59 Go to next message
Adrian Herscu is currently offline Adrian HerscuFriend
Messages: 33
Registered: July 2009
Member
Hi all,

I am trying to build a meta-model which describes an application that
contains types, which contain fields.

Application <>--0..* Type
Type <>--0..* Field

Type has a name attribute. Field has a name attribute too.
Field also has a type reference (EReference). In the instance the
reference should be of an existing Type.

So far so good. But how to add primitive types to the system without
requiring the user to define them as "Type"-s?

My current solution is to add an enumerated "kind" attribute to the
Field. Any better ideas?

Adrian.
Re: EReference and primitive types [message #429943 is a reply to message #429936] Thu, 07 May 2009 09:30 Go to previous messageGo to next message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Hi Adrian,

what I would do is to describe types with a type hierarchy like so:

AbstractType<>--0..* Field

AbstractType <|--+- PrimitiveType
|
'- ComplexType

You may extend PrimitiveType further with Integer, String, etc. This has
the advantage that you specify the available primitive types in your
meta model.

You may alternativly define an enumeration attribute with PrimitiveType.
Then you would need to add an EEnum with the respective constants.

You may also add an attribute of type java.lang.class to AbstractType.

It really depends on your application on what approach fits best.

Anyway you need to provide some code that creates the PrimitiveType
instances I believe. You may use reflection mechanisms to find them if
you used the "extend PrimitiveType" approach.

Regards,
Dirk



Adrian Herscu schrieb:
> Hi all,
>
> I am trying to build a meta-model which describes an application that
> contains types, which contain fields.
>
> Application <>--0..* Type
> Type <>--0..* Field
>
> Type has a name attribute. Field has a name attribute too.
> Field also has a type reference (EReference). In the instance the
> reference should be of an existing Type.
>
> So far so good. But how to add primitive types to the system without
> requiring the user to define them as "Type"-s?
>
> My current solution is to add an enumerated "kind" attribute to the
> Field. Any better ideas?
>
> Adrian.
Re: EReference and primitive types [message #429967 is a reply to message #429943] Thu, 07 May 2009 16:39 Go to previous message
Adrian Herscu is currently offline Adrian HerscuFriend
Messages: 33
Registered: July 2009
Member
Hi Dirk, and thanks for your fast reply :)

Dirk Hoffmann wrote:
> Hi Adrian,
>
> what I would do is to describe types with a type hierarchy like so:
>
> AbstractType<>--0..* Field
>
> AbstractType <|--+- PrimitiveType
> |
> '- ComplexType
>
> You may extend PrimitiveType further with Integer, String, etc. This has
> the advantage that you specify the available primitive types in your
> meta model.

Unfortunately, this requires the user to define the primitive types in
his model instance.

>
> You may alternativly define an enumeration attribute with PrimitiveType.
> Then you would need to add an EEnum with the respective constants.
>
> You may also add an attribute of type java.lang.class to AbstractType.
>
> It really depends on your application on what approach fits best.
>
> Anyway you need to provide some code that creates the PrimitiveType
> instances I believe. You may use reflection mechanisms to find them if
> you used the "extend PrimitiveType" approach.

The solution I have found is to make Field abstract and extend it with a
Reference (that is associated with a Type) and with an Attribute (that
has "type" attribute with a Primitive EType, where "Primitive" is
defined as an EEnum enumerating the available primitives).

>
> Regards,
> Dirk
>
>
>
> Adrian Herscu schrieb:
>> Hi all,
>>
>> I am trying to build a meta-model which describes an application that
>> contains types, which contain fields.
>>
>> Application <>--0..* Type
>> Type <>--0..* Field
>>
>> Type has a name attribute. Field has a name attribute too.
>> Field also has a type reference (EReference). In the instance the
>> reference should be of an existing Type.
>>
>> So far so good. But how to add primitive types to the system without
>> requiring the user to define them as "Type"-s?
>>
>> My current solution is to add an enumerated "kind" attribute to the
>> Field. Any better ideas?
>>
>> Adrian.
Previous Topic:EMF performance
Next Topic:[CDO] Passive updates
Goto Forum:
  


Current Time: Tue Sep 24 14:45:08 GMT 2024

Powered by FUDForum. Page generated in 0.03748 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top