Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Checking whether "self" is a reference of it's "container"
Checking whether "self" is a reference of it's "container" [message #42386] Thu, 01 November 2007 00:48 Go to next message
Eclipse User
Originally posted by: marco.pantel.unibw.de

Good morning!

I've been trying to find a solution to my problem for a while now but I
just can't find it...

Imagine the following situation in my ecore:

an EClass, e.g. "Calculation", contains two EReferences, let's say
"function" and "argument".
Another EClass, "Variable", which can be each of these references has
got an ocl-constraint.
Though the constraint should not be active when Variable acts as
"function", I wanted to check, if the "argument" of the container
(=Calculation) of Variable is the Variable itself.
My first approach was something like "self.container.argument=self" but
that is neither beautiful nor did it work... ;-)

Can anybody help me?


Regards, Marco
Re: Checking whether "self" is a reference of it's "container" [message #42541 is a reply to message #42386] Thu, 01 November 2007 14:28 Go to previous message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Marco,

If you have a container reference defined from Variable to Calculation
(i.e., an EReference whose eOpposite is the containment EReference from
Calculation to Variable), then you will be able to do what you need.

So, if you have

EClass Calculation
EReference variable : Variable [0..*]
{isContainment}
{eOpposite = Variable::calculation}

EClass Variable
EReference calculation : Calculation [0..1]
{eOpposite = Calculation::variable}

then you can do

self.calculation.argument = self

in the context of the Variable EClass.

Of course, if and when https://bugs.eclipse.org/bugs/show_bug.cgi?id=152003
is implemented (which is more feasible now that we have the new-in-M3
support for OCL parser warnings and problem options), you would be able to
do

self.eContainer().oclIsKindOf(Calculation) and
self.eContainer().oclAsType(Calculation).argument = self

which is more ugly anyway. :-)

HTH,

Christian


Marco Pantel wrote:

> Good morning!
>
> I've been trying to find a solution to my problem for a while now but I
> just can't find it...
>
> Imagine the following situation in my ecore:
>
> an EClass, e.g. "Calculation", contains two EReferences, let's say
> "function" and "argument".
> Another EClass, "Variable", which can be each of these references has
> got an ocl-constraint.
> Though the constraint should not be active when Variable acts as
> "function", I wanted to check, if the "argument" of the container
> (=Calculation) of Variable is the Variable itself.
> My first approach was something like "self.container.argument=self" but
> that is neither beautiful nor did it work... ;-)
>
> Can anybody help me?
>
>
> Regards, Marco
Previous Topic:Re: Error by EMF-Update
Next Topic:OCL expr as an initializer
Goto Forum:
  


Current Time: Sun Sep 21 10:27:41 GMT 2014

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

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