Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Custom primitive types
Custom primitive types [message #1386974] Mon, 23 June 2014 10:59 Go to next message
Eclipse UserFriend
Dear all,
I'm creating a profile where I would need to use extensively unsigned 32
bit integers (uint32).

To use uint32 I would have to use EMF's ELong, since Int primitive type
in UML is a signed int 32, thus the range is not enough for an uint32.

What I would like to achieve is to create a primite type for uint32
where I can specify the range constraint, and therefore avoid adding the
same constraints for every ELong in my profile.
Is it possible?

Greeting,

Victor
Re: Custom primitive types [message #1386993 is a reply to message #1386974] Mon, 23 June 2014 12:23 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1207
Registered: July 2009
Location: Canada
Senior Member

Hi, Victor,

Yes, it is possible. Just create an instance of the PrimitiveType
metaclass in your profile. Or, more probably, you should define it in
a library model that can be shared by your profile and the models that
profile is applied to. This is exactly how the UML standard
PrimitiveTypes library is used.

If you want to, you can use the <<EDataType>> stereotype from the Ecore
profile to tag your uint32 primitive type with the 'instanceClassName'
(int, long, or whatever) that should represent it in Java code, but
perhaps your domain isn't Java anyways so it doesn't matter.

I haven't looked into it, but I would expect the C++ code generator in
the Qompass component of Papyrus would probably have a library of types
that includes unsigned integral types; you might look at that for ideas.

HTH,

Christian

On 2014-06-23 10:59:54 +0000, V. López said:

> Dear all,
> I'm creating a profile where I would need to use extensively unsigned
> 32 bit integers (uint32).
>
> To use uint32 I would have to use EMF's ELong, since Int primitive type
> in UML is a signed int 32, thus the range is not enough for an uint32.
>
> What I would like to achieve is to create a primite type for uint32
> where I can specify the range constraint, and therefore avoid adding
> the same constraints for every ELong in my profile.
> Is it possible?
>
> Greeting,
>
> Victor
Re: Custom primitive types [message #1388485 is a reply to message #1386993] Thu, 26 June 2014 14:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6795
Registered: July 2009
Senior Member
Hi

On 23/06/2014 13:23, Christian W. Damus wrote:
> If you want to, you can use the <<EDataType>> stereotype from the
> Ecore profile to tag your uint32 primitive type with the
> 'instanceClassName' (int, long, or whatever) that should represent it
> in Java code, but perhaps your domain isn't Java anyways so it doesn't
> matter.
You must do this if you want to use OCL so that it can determine the
behavioral type of your non-standard type.

Regards

Ed Willink
Re: Custom primitive types [message #1389142 is a reply to message #1388485] Fri, 27 June 2014 11:49 Go to previous messageGo to next message
Eclipse UserFriend
Thanks, that was exactly was I was trying to achieve.

Regards,

Víctor

El 26/06/2014 16:07, Ed Willink escribió:
> Hi
>
> On 23/06/2014 13:23, Christian W. Damus wrote:
>> If you want to, you can use the <<EDataType>> stereotype from the
>> Ecore profile to tag your uint32 primitive type with the
>> 'instanceClassName' (int, long, or whatever) that should represent it
>> in Java code, but perhaps your domain isn't Java anyways so it doesn't
>> matter.
> You must do this if you want to use OCL so that it can determine the
> behavioral type of your non-standard type.
>
> Regards
>
> Ed Willink
Re: Custom primitive types [message #1389150 is a reply to message #1388485] Fri, 27 June 2014 12:00 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
What's the property to constraint the range in a numerical type?
Imagine I have an <<EDataType>>, with its instanceClassName set to
"int". Now I want the value that this new type accepts be greater than 0
and lower than 2000 (for instance).

Regards,

Víctor

El 26/06/2014 16:07, Ed Willink escribió:
> Hi
>
> On 23/06/2014 13:23, Christian W. Damus wrote:
>> If you want to, you can use the <<EDataType>> stereotype from the
>> Ecore profile to tag your uint32 primitive type with the
>> 'instanceClassName' (int, long, or whatever) that should represent it
>> in Java code, but perhaps your domain isn't Java anyways so it doesn't
>> matter.
> You must do this if you want to use OCL so that it can determine the
> behavioral type of your non-standard type.
>
> Regards
>
> Ed Willink
Re: Custom primitive types [message #1389275 is a reply to message #1389150] Fri, 27 June 2014 15:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6795
Registered: July 2009
Senior Member
Hi

You've hit my favorite missing UML feature.

It was introduced in Executable UML but never got promoted back into
core UML.

I suspect that MARTE or SysML have it, so that you can at least use a
standard although inconvenient stereotype.

Regards

Ed Willink


On 27/06/2014 13:00, "V. López" wrote:
> Hi,
> What's the property to constraint the range in a numerical type?
> Imagine I have an <<EDataType>>, with its instanceClassName set to
> "int". Now I want the value that this new type accepts be greater than
> 0 and lower than 2000 (for instance).
>
> Regards,
>
> Víctor
>
> El 26/06/2014 16:07, Ed Willink escribió:
>> Hi
>>
>> On 23/06/2014 13:23, Christian W. Damus wrote:
>>> If you want to, you can use the <<EDataType>> stereotype from the
>>> Ecore profile to tag your uint32 primitive type with the
>>> 'instanceClassName' (int, long, or whatever) that should represent it
>>> in Java code, but perhaps your domain isn't Java anyways so it doesn't
>>> matter.
>> You must do this if you want to use OCL so that it can determine the
>> behavioral type of your non-standard type.
>>
>> Regards
>>
>> Ed Willink
>
Re: Custom primitive types [message #1390978 is a reply to message #1389275] Mon, 30 June 2014 09:06 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
Fully aggree. Having this feature in UML is a must.
a Primitive Type is more than just a name.
Would it be possible to create a single constraint in a profile so that
every tagged value of that type is affected?

Regards,

Víctor

El 27/06/2014 17:11, Ed Willink escribió:
> Hi
>
> You've hit my favorite missing UML feature.
>
> It was introduced in Executable UML but never got promoted back into
> core UML.
>
> I suspect that MARTE or SysML have it, so that you can at least use a
> standard although inconvenient stereotype.
>
> Regards
>
> Ed Willink
>
>
> On 27/06/2014 13:00, "V. López" wrote:
>> Hi,
>> What's the property to constraint the range in a numerical type?
>> Imagine I have an <<EDataType>>, with its instanceClassName set to
>> "int". Now I want the value that this new type accepts be greater than
>> 0 and lower than 2000 (for instance).
>>
>> Regards,
>>
>> Víctor
>>
>> El 26/06/2014 16:07, Ed Willink escribió:
>>> Hi
>>>
>>> On 23/06/2014 13:23, Christian W. Damus wrote:
>>>> If you want to, you can use the <<EDataType>> stereotype from the
>>>> Ecore profile to tag your uint32 primitive type with the
>>>> 'instanceClassName' (int, long, or whatever) that should represent it
>>>> in Java code, but perhaps your domain isn't Java anyways so it doesn't
>>>> matter.
>>> You must do this if you want to use OCL so that it can determine the
>>> behavioral type of your non-standard type.
>>>
>>> Regards
>>>
>>> Ed Willink
>>
>
Re: Custom primitive types [message #1449456 is a reply to message #1388485] Tue, 21 October 2014 11:38 Go to previous message
Víctor López is currently offline Víctor LópezFriend
Messages: 22
Registered: June 2014
Junior Member
Dear All,
I did like this, created a primitive UML datatype, applied the <<EDataType>> stereotype and set 'instanceClassName' to int.
However, when I write OCL constraints I have to write self.myCustomTypeAttribute.oclTypeAs(Integer) for the OCL to work.
Is that the expected behaviour?
The editor for myCustomTypeAttribute works perfectly and I can set its value in the tagged values section in the class I apply the profile.

Regards,

Víctor

P.S. Using Luna and Papyrus 1.0.

Ed Willink wrote on Thu, 26 June 2014 10:07
Hi

On 23/06/2014 13:23, Christian W. Damus wrote:
> If you want to, you can use the <<EDataType>> stereotype from the
> Ecore profile to tag your uint32 primitive type with the
> 'instanceClassName' (int, long, or whatever) that should represent it
> in Java code, but perhaps your domain isn't Java anyways so it doesn't
> matter.
You must do this if you want to use OCL so that it can determine the
behavioral type of your non-standard type.

Regards

Ed Willink

Previous Topic:Cannot apply UML-RT State Machine stereotype
Next Topic:inter-models validation
Goto Forum:
  


Current Time: Sat Aug 08 01:17:51 GMT 2020

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

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

Back to the top