Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » define a operation for a given type.
define a operation for a given type. [message #35271] Fri, 03 August 2007 22:59 Go to next message
Eclipse User
Originally posted by: firstname.name.gmail.com

Hello,

I have some questions on the mechanisms entailed to create operation in
environment. When we create a operation (for example with the defineOperation
method), we have to precise its context classifier.

In a uml environment, I would expect to make available a given operation only
for a given type. For example, to create an operation for only usable for the
context package. To do that I have to retrieve at first its context. It is its
metaclass (for example with getMetclass(Package)).

but I should do something wrong because It doesn't work. To add a operation on a
Package, I have to use the context owner OclAny.

If I debug it, I can see, that environment operation found for Package are those
for OclAny (UMLReflection will be invoked at first for Package, then for
OclAnyVoid). At some point, I understand that a user operation can't be "added"
in the corresponding classifier, and so that the classifier.getAllOperation()
may not include my operation.

So my question is to know if/how I may restrict a operation/variable for a type.

thanks a lot.
--
F. Lagarde
Re: define a operation for a given type. [message #35508 is a reply to message #35271] Tue, 07 August 2007 16:55 Go to previous message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Fran├žois,

This seems to work for me. I can define the following in text:

package uml
context Package
def: foo() : Boolean = true
endpackage

And use this in a constraint defined in the context of the Model metaclass
(which specializes package).

So, perhaps there is something wrong with the way that you are using the
define(...) operation. Try debugging the OCLParser::defCS(...) method to
see how the parser defines operations from text.

HTH,

Christian

Fran├žois Lagarde wrote:

> Hello,
>
> I have some questions on the mechanisms entailed to create operation in
> environment. When we create a operation (for example with the
> defineOperation method), we have to precise its context classifier.
>
> In a uml environment, I would expect to make available a given operation
> only for a given type. For example, to create an operation for only usable
> for the context package. To do that I have to retrieve at first its
> context. It is its metaclass (for example with getMetclass(Package)).
>
> but I should do something wrong because It doesn't work. To add a
> operation on a Package, I have to use the context owner OclAny.
>
> If I debug it, I can see, that environment operation found for Package are
> those for OclAny (UMLReflection will be invoked at first for Package, then
> for OclAnyVoid). At some point, I understand that a user operation can't
> be "added" in the corresponding classifier, and so that the
> classifier.getAllOperation() may not include my operation.
>
> So my question is to know if/how I may restrict a operation/variable for a
> type.
>
> thanks a lot.
Previous Topic:handling setters.
Next Topic:OCL, precondition of an operation
Goto Forum:
  


Current Time: Fri Sep 19 08:08:55 GMT 2014

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

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