|Re: Shorten oclAsType and obtain all instances [message #527772 is a reply to message #527759]
||Fri, 16 April 2010 12:18
| Laurent Goubet
Registered: July 2009
This is a multi-part message in MIME format.|
Content-Type: text/plain; charset=UTF-8; format=flowed
As far as your first issue is concerned (forced oclAsType after a
"select(oclIsKindOf(...))"), this is a problem I discussed a good while
ago when Christian Damus was the lead OCL commiter. His answer can be
IIRC, base point was that the OCL specification explicitely states the
return type of the select operation, thus preventing dynamic casting
even if the select's expression ends in "oclIsKindOf" (Don't get me
wrong, I'd be all for deviating from the spec on this, but doubt it will
As for the second, you could use the "allInstances" operation. To keep
your example, here is how you'd get a set with the names of all your
> I'm new to OCL and I've been running into two problems. At the moment
> I'm working with Topcased which seems to be running alright.
> First of all, when I use the 'select' operation I have to use the
> 'oclAsType' operation to continue with the retrieved collection.
> For instance, lets say I'm looking at an object 'Company' which has
> different 'workfloors': 'shop' and 'storage'. If I want to see which
> products are in the storage I'll have to type something like:
> context Company:
> Is there perhaps some way I can leave the 'oclAsType(Storage)' out of
> this function? Because in some bigger constraints it makes it very
> chaotic. And in my opinion I've already stated that I'm using the object
> 'Storage' since I've only selected those. But right now in Topcased
> atleast I can't seem to use the '.products' operation if I don't declare
> that my selection is oclAsType(Storage).
> And a second issue I'm having is whether there is a way to obtain all
> instances of a model with a single operation. For example I'd like to
> get a collection with all names of all classes. Do I really have to work
> through the entire model and retrieve every name or is there a shortcut
> to do this?
> Thanks in advance, I hope the problems are clear enough like this.
Content-Type: text/x-vcard; charset=utf-8;
Powered by FUDForum
. Page generated in 0.08539 seconds