Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Creating centralised datatypes model
Creating centralised datatypes model [message #629843] Wed, 29 September 2010 17:51 Go to next message
Alan  is currently offline Alan Friend
Messages: 4
Registered: August 2010
Junior Member
Hi all,

I am looking to create a centralised datatypes model that can be shared by different models across the toolsuite we are creating.
So for example we need the simple types like Bool, Int etc but also the more complex types like arrays.
With the simple types its pretty straightforward as they cannot be configured and as such can be shared by everyone who needs a bool.
The model is saved in its own resource with the Datatypes container having datatypes in it (containment= true) and all referencing objects from other models having references to these types (containment=false).
So if two models used a bool they'd both point to the same object (via a href) in this central resource.

So far so good. But when it comes to arrays for example we have an issue. These are configured with contained types (arrays of bools, ints etc) and also with bounds (0..10, 0..100 etc) so in this case having them centrally contained is a little less clear to me.
I tried to have the create methods on the factory take parameters but this caused an issues on loading of resources when the create(ECLass) method of the factory is used as I cannot see how this can pass the parameters I need to the constructor.

I could have simple types contained centrally and complex types contained by the seperate models but I would need two attrs for this then surely ? (simpleDatatype, complexDatatype when I can only have one datatype)

Has anyone built such a model and if so got any advice ?
Also can EDatatype help me in this ?

thanks,
Alan.
Re: Creating centralised datatypes model [message #629855 is a reply to message #629843] Wed, 29 September 2010 18:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Alan,

Comments below.


Alan wrote:
> Hi all,
>
> I am looking to create a centralised datatypes model that can be
> shared by different models across the toolsuite we are creating. So
> for example we need the simple types like Bool, Int etc
EcorePackage and XMLTypePackage both provides those already.
> but also the more complex types like arrays.
There are many types of arrays. Things like EByteArray are provided by
EcorePackage and XMLTypePackage...
>
> With the simple types its pretty straightforward as they cannot be
> configured and as such can be shared by everyone who needs a bool.
By configured you mean they are immutable...
> The model is saved in its own resource with the Datatypes container
> having datatypes in it (containment= true) and all referencing objects
> from other models having references to these types (containment=false).
So you want to have objects that contain your values?
> So if two models used a bool they'd both point to the same object (via
> a href) in this central resource.
You'd want, for example, a single EObject to represent a wrapper for the
boolean value true?
>
> So far so good. But when it comes to arrays for example we have an
> issue. These are configured with contained types (arrays of bools,
> ints etc) and also with bounds (0..10, 0..100 etc) so in this case
> having them centrally contained is a little less clear to me. I tried
> to have the create methods on the factory take parameters but this
> caused an issues on loading of resources when the create(ECLass)
> method of the factory is used as I cannot see how this can pass the
> parameters I need to the constructor.
Deserialization generally creates empty instances which are then
populated as the information about them is deserialized...
>
> I could have simple types contained centrally and complex types
> contained by the seperate models but I would need two attrs for this
> then surely ? (simpleDatatype, complexDatatype when I can only have
> one datatype) .
I'm having a hard time trying to figure out what's motivating this. I
can't imagine it's a good thing for there to be a central place that
stores all integer values being used, and all floats, and so on. I
imagine it's generally good to store that information about the value at
the point it's used.
>
> Has anyone built such a model and if so got any advice ?
It's a little hard to imagine why you'd want this.
> Also can EDatatype help me in this ?
How come you can't use reuse EMF existing data types and define new ones
for the types not already supported? What's the purpose of this
centralized place to store wrappers for all values?
>
> thanks,
> Alan.
Re: Creating centralised datatypes model [message #629984 is a reply to message #629855] Thu, 30 September 2010 08:45 Go to previous messageGo to next message
Alan  is currently offline Alan Friend
Messages: 4
Registered: August 2010
Junior Member
Hi Ed,

thanks for the reply. I think I should maybe state the problem from scratch rather than attempt to answer the questions individually. I started with the idea of a centralised model but let me take a step back and define the issues.

Ok so we are developing an editor for a language. Variables in this language have a dataype attribute. These can be primitive type such as Bool and Int but can also be User defined so the user can define their own extension of primitive types. They can also define their own Structs which mean they can combine types in another type.

We also have other seperate tools (non language editors) that have objects with types. We need to be able to connect objects from the two different tools together and whether they can be connected will be determined (to start with at least) on their datatypes. So if both are bool then they are ok for connection for example. Some complex types such as Structs will be pre-configured and as such can also be shared between the tools (consider it a library of types if you will)

As all tools (current and future) have types I thought to create a central shared type model. As you point out a lot of what I need is already available.

"How come you can't use reuse EMF existing data types and define new ones for the types not already supported?"
I guess the answer to this is that I can see no reason. Let me ask you this - I have a Class Variable and it has an attribute datatype. Using the re-use approach what type would datatype be ?

Hope I was clear enough on what we need. If not please let me know.

thanks,
Alan
Re: Creating centralised datatypes model [message #630053 is a reply to message #629984] Thu, 30 September 2010 14:05 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Alan,

Comments below.


Alan wrote:
> Hi Ed,
> thanks for the reply. I think I should maybe state the problem from
> scratch rather than attempt to answer the questions individually. I
> started with the idea of a centralised model but let me take a step
> back and define the issues.
>
> Ok so we are developing an editor for a language.
You're looking at using Xtext?
> Variables in this language have a dataype attribute. These can be
> primitive type such as Bool and Int but can also be User defined so
> the user can define their own extension of primitive types. They can
> also define their own Structs which mean they can combine types in
> another type.
Okay, so there's a type system. The Xtext folks are working on
something they call Xbase to help implement a common core for typed
expression languages.
>
> We also have other seperate tools (non language editors) that have
> objects with types. We need to be able to connect objects from the two
> different tools together and whether they can be connected will be
> determined (to start with at least) on their datatypes.
I see.
> So if both are bool then they are ok for connection for example. Some
> complex types such as Structs will be pre-configured and as such can
> also be shared between the tools (consider it a library of types if
> you will)
So some times are "built-in" while others are user defined in the language.
> As all tools (current and future) have types I thought to create a
> central shared type model. As you point out a lot of what I need is
> already available.
> "How come you can't use reuse EMF existing data types and define new
> ones for the types not already supported?"
> I guess the answer to this is that I can see no reason. Let me ask you
> this - I have a Class Variable and it has an attribute datatype. Using
> the re-use approach what type would datatype be ?
Given that types can be defined by the user, it seems best to treat
built-in ones as much like that as possible. Compare it to XML Schema
for example. You can define simple and complex types in schemas, but
there is a set of built-in simple types. Those are defined in a schema
schema XMLSchema.xsd and those are ubiquitously available in all other
schemas. So from the point of view of a model for XML Schema, there is
just a "special schema" and this ends up acting like a central
instance. Ecore's EcorePackage and XMLTypePackage end up performing
that role for Ecore. It sounds like you want that type of concept for
your language.

Have a look at XText and XBase as well; you might find that 90% of what
you're trying to do has been well thought out already.
>
> Hope I was clear enough on what we need. If not please let me know.
>
> thanks,
> Alan
Previous Topic:Repopulating a table in the dialog on checkbox selection
Next Topic:EclipseLink JPA2.0 orm table name prefix help
Goto Forum:
  


Current Time: Fri Oct 18 01:36:28 GMT 2019

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

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

Back to the top