|
|
Re: Shorten oclAsType and obtain all instances [message #527772 is a reply to message #527759] |
Fri, 16 April 2010 12:18 |
|
This is a multi-part message in MIME format.
--------------040801010103080109050107
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Micha,
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
read on
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.o cl/msg01881.html
..
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
be done).
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
classes :
Class.allInstances().name
Laurent Goubet
Obeo
Micha wrote:
> Hello,
>
> 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:
>
> self.workfloors->select(oclIsTypeOf(Storage)).oclAsType(Storage).products
>
> 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.
>
> Greetings,
> Micha
--------------040801010103080109050107
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------040801010103080109050107--
|
|
|
|
Powered by
FUDForum. Page generated in 0.02215 seconds