Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » User-defined reusable type of properties and enumerations in "library" models
User-defined reusable type of properties and enumerations in "library" models [message #1281771] Tue, 01 April 2014 10:27 Go to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
Hi,

I'm wondering if it is possible to define reusable types of properties that could be "instantiated" into model elements. A concrete example, in a first model, I would define a property type with something like:

declare property(Speed,integer)

and use it another model with
use property(Speed,120)

So, I would have some kind of dynamic binding from the type of the property as defined in a "declare" statement and its "usage" with the value specified in its instance.

For the definition rule, it's pretty simple, but I'm puzzled on how to define the other one; especially to avoid defining all values as strings.

A somewhat related question would be if there is a way to define enumerations in a similar way, with something like

type myenumeration values { value1, value2, value3 }

and also being able to instantiate it the same way as I did upper for simple types.

Any help, hint or pointers would be much appreciated.
Cheers,

Fabian
Re: User-defined reusable type of properties and enumerations in "library" models [message #1281779 is a reply to message #1281771] Tue, 01 April 2014 10:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13314
Registered: July 2009
Senior Member
HI,

what about defining expressions for the values.
and having a stringliteral, intliteral, booleanliteral etc
+ a type system/check for consitencies?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: User-defined reusable type of properties and enumerations in "library" models [message #1281786 is a reply to message #1281779] Tue, 01 April 2014 10:55 Go to previous message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
I effectively thought about it (had a look at Markus Voelter TS), but it now looks more clear as you tell me to do it like this.
Thanks Christian, as usual, you were as fast as accurate!
Previous Topic:Rule is treated as Uncalled rule even if called
Next Topic:Null references in Xtext when we do a clean build
Goto Forum:
  


Current Time: Thu Jan 23 01:20:42 GMT 2020

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

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

Back to the top