Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Composing instances of a used-defined type(Composing instances of a used-defined type)
Composing instances of a used-defined type [message #493701] Tue, 27 October 2009 15:39 Go to next message
Bjorn Mising name is currently offline Bjorn Mising name
Messages: 3
Registered: October 2009
Junior Member
Hello,

Is it possible to create and fill instances of a user-defined type?

For example: The user-defined type Person is composed of the following two attributes:
- name : string
- age : integer

Further a Class is defined with two attributes:
- p : string
- a : integer
and one operation:
- ComposePerson : Person

The idea is to define an OCL body expression for the operation that returns a single instance of type Person, filled with the values of the 'p' and 'a' instance values of the class instance.

So if p = "John" and a = 15, then the result of the operation shall be: { "John", 15 } (of type Person).


With kind regards,
Bjorn
Re: Composing instances of a used-defined type [message #493766 is a reply to message #493701] Tue, 27 October 2009 21:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Bjorn

This was raised as OMG Issue 13057, where for your example the proposed
Tuple-like constructor might be:

Person{name = "John", age = 15}

The idea seems syntactically and semantically sound but awaits
further analysis and prototyping.

Regards

Ed Willink

Bjorn wrote:
> Hello,
>
> Is it possible to create and fill instances of a user-defined type?
> For example: The user-defined type Person is composed of the following
> two attributes:
> - name : string
> - age : integer
>
> Further a Class is defined with two attributes:
> - p : string
> - a : integer
> and one operation:
> - ComposePerson : Person
>
> The idea is to define an OCL body expression for the operation that
> returns a single instance of type Person, filled with the values of the
> 'p' and 'a' instance values of the class instance.
>
> So if p = "John" and a = 15, then the result of the operation shall be:
> { "John", 15 } (of type Person).
>
>
> With kind regards,
> Bjorn
>
Re: Composing instances of a used-defined type [message #493902 is a reply to message #493701] Wed, 28 October 2009 13:03 Go to previous messageGo to next message
Bjorn Mising name is currently offline Bjorn Mising name
Messages: 3
Registered: October 2009
Junior Member
Hello Edward,

Thank you for your quick response. The issue you mention is exact that what I need. So this means I need to be patient Wink For now I will try to work-around this issue.

Kind regards,
Bjorn
Re: Composing instances of a used-defined type [message #494046 is a reply to message #493902] Wed, 28 October 2009 21:51 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Bjorn

I had a quick play at a modified grammar. With Issue 14583 making Tuple
partially reserved, there is no syntactic prpblem with the extension.
It's just a matter of sorting out default values, and a treatment for
uninitialised values.

We might get a prototype in for Helios.

Watch https://bugs.eclipse.org/bugs/show_bug.cgi?id=293622 to see when
something's available.

Regards

Ed Willink


Bjorn wrote:
> Hello Edward,
>
> Thank you for your quick response. The issue you mention is exact that
> what I need. So this means I need to be patient ;) For now I will try to
> work-around this issue.
>
> Kind regards, Bjorn
>
Previous Topic:OCL Syntax check
Next Topic:Different Figures for one Ecore class
Goto Forum:
  


Current Time: Sat Oct 25 08:01:24 GMT 2014

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

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