Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Initialise Map in OCL
Initialise Map in OCL [message #1797996] Fri, 09 November 2018 16:40 Go to next message
Florian Amberg is currently offline Florian AmbergFriend
Messages: 6
Registered: November 2018
Junior Member
Hello,
I need to store some values in a Map where the keys and values are Tuples of Strings. I currently have my Pseudomap declared like this:
def: 
rel : Set(
	Tuple(
		k : Tuple(rst : String, ct : String),
		v : Tuple(rt1 : String, rt2 : String)
	)
) = 

It is working, but I rather have a real Map.
In the OCL standard library, it says, that a Map(K, V) type is supported, but I cannot seem to make it work and i cannot find an example of how to use it. So could someone give me an example of how to use the Map type in OCL?

Regards
Re: Initialise Map in OCL [message #1798207 is a reply to message #1797996] Wed, 14 November 2018 08:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Sorry for the slow response; it seems to have taken four days for the RDF notification to be sent...

It doesn't work is never a useful comment. What doesn't work?

The Map type was added a couple of years ago and AFAIAA has not been used beyond my test cases see [1].

However in the last couple of months there have been four inquiries about Map, prompting me to review what's there.

Map construction is poor [2]. You need to iterate an including resulting in a poor quadratic performance.

Map iteration is missing [3]. You need to use keys() to obtain a suitable set of keys to iterate over, and perhaps a let to cache the map for map->at(key).

But it does work (until someone raises a specific bug).

I did some coding on the Bugzillas a week ago, but got discouraged by the need for a new IterableType in the metamodel which is too big a change for the +0.0.1 release planned for December. However your further inquiry may tip the balance so that Map can be more effective in a +0.1.0 release in December. A preliminary release might be available as the third milestone in two weeks.

Regards

Ed Willink

[1] http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateMapOperationsTest4.java
[2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=540353
[3] https://bugs.eclipse.org/bugs/show_bug.cgi?id=540884
Re: Initialise Map in OCL [message #1798229 is a reply to message #1798207] Wed, 14 November 2018 14:14 Go to previous messageGo to next message
Florian Amberg is currently offline Florian AmbergFriend
Messages: 6
Registered: November 2018
Junior Member
Hey Ed,
that first example is really helpful, thank you very much.
Re: Initialise Map in OCL [message #1798638 is a reply to message #1798229] Wed, 21 November 2018 14:06 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The improved Map functionality discussed in [2], [3] is now available as [4]. The N&N at [1] has some minimal examples.

Regards

Ed Willink

[1] https://wiki.eclipse.org/OCL/New_and_Noteworthy/2018-12
[2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=540353
[3] https://bugs.eclipse.org/bugs/show_bug.cgi?id=540884
[4] http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/6.6.0/I201811211206/mdt-ocl-Update-I201811211206.zip
Previous Topic:Specify Constraint for Parameter of a UML Operation
Next Topic:Map type support in OCL?
Goto Forum:
  


Current Time: Thu Apr 25 22:00:53 GMT 2024

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

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

Back to the top