Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » recursion
recursion [message #41558] Wed, 24 October 2007 10:21 Go to next message
Eclipse UserFriend
Originally posted by: nickkirtley.gmail.com

hi,

I have a model, and in that model there are a number of aggregated
components.
c1 aggregates c2, c2 agg. c3, c3 to c4 etc.
I then want a list of the aggregated components. The problem is that I
don't how many components there are. How can solve this problem in a query?

regards,
nick
Re: recursion [message #41580 is a reply to message #41558] Wed, 24 October 2007 12:26 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Nick,

If you don't mind using non-standard OCL capabilities (and, in the latest
I-build, getting warnings when you use them), then you can try our custom
"closure" iterator:

self->closure(
attribute->select(aggregation <> AggregationKind::none).type->select(
oclIsKindOf(Component))

This gets the transitive closure, starting from the self component, of all
components related by an aggregation attribute (in the aggregating
direction).

If you need to use only standard OCL, then you would probably have to define
a recursive helper operation using a def: expression.

HTH,

Christian


Nick Kirtley wrote:

> hi,
>
> I have a model, and in that model there are a number of aggregated
> components.
> c1 aggregates c2, c2 agg. c3, c3 to c4 etc.
> I then want a list of the aggregated components. The problem is that I
> don't how many components there are. How can solve this problem in a
> query?
>
> regards,
> nick
Previous Topic:Where are the constraints???
Next Topic:ocl operation and parameter type.
Goto Forum:
  


Current Time: Fri Apr 19 09:46:44 GMT 2024

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

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

Back to the top