Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL: how to constraints two properties to have the same type ?
OCL: how to constraints two properties to have the same type ? [message #1013] Tue, 23 January 2007 10:45 Go to next message
Eclipse UserFriend
Originally posted by: sylvain.maillard.univ-nantes.fr

Hi All,

I'm new to OCL, and I've a EMF model that contains a class with two
properties. I want this two properties to be of the same type. Is it
possible to do this with OCL ?
For now I have a constraints like: inv: self.prop1.oclIsTypeOf(MyType)
and self.prop2.oclIsTypeOf(MyType) ..
and I want something like: inv:
self.prop1.oclIsTypeOf(self.prop2.getTheTypeOfThisProperties )

Thanks in advance,

Regards,
Sylvain
Re: OCL: how to constraints two properties to have the same type ? [message #1041 is a reply to message #1013] Tue, 23 January 2007 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Sylvain,

Unfortunately, OCL 2.0 does not provide an operation that obtains the
run-time type of an object. You can only query whether an object is of a
known type (as in your first example). It sure would be nice to have an
operation

OclAny::oclType() : OclType

wouldn't it? You can actually define this for yourself by extending the
EcoreEnvironment and EvalEnvironment classes. Have a look at Chris Lenz's
Example on the OCL Wiki page that illustrates how to do this:

http://wiki.eclipse.org/index.php/CustomizingOclEnvironments

Cheers,

Christian


Sylvain wrote:

> Hi All,
>
> I'm new to OCL, and I've a EMF model that contains a class with two
> properties. I want this two properties to be of the same type. Is it
> possible to do this with OCL ?
> For now I have a constraints like: inv: self.prop1.oclIsTypeOf(MyType)
> and self.prop2.oclIsTypeOf(MyType) ..
> and I want something like: inv:
> self.prop1.oclIsTypeOf(self.prop2.getTheTypeOfThisProperties )
>
> Thanks in advance,
>
> Regards,
> Sylvain
Re: OCL: how to constraints two properties to have the same type ? [message #1069 is a reply to message #1041] Tue, 23 January 2007 16:22 Go to previous message
Eclipse UserFriend
Originally posted by: sylvain.maillard.univ-nantes.fr

Christian W. Damus a écrit :
> Hi, Sylvain,
>
> Unfortunately, OCL 2.0 does not provide an operation that obtains the
> run-time type of an object. You can only query whether an object is of a
> known type (as in your first example). It sure would be nice to have an
> operation
>
> OclAny::oclType() : OclType
>
> wouldn't it? You can actually define this for yourself by extending the
> EcoreEnvironment and EvalEnvironment classes. Have a look at Chris Lenz's
> Example on the OCL Wiki page that illustrates how to do this:
>
> http://wiki.eclipse.org/index.php/CustomizingOclEnvironments
>
> Cheers,
>
> Christian
>
>
> Sylvain wrote:
>
>> Hi All,
>>
>> I'm new to OCL, and I've a EMF model that contains a class with two
>> properties. I want this two properties to be of the same type. Is it
>> possible to do this with OCL ?
>> For now I have a constraints like: inv: self.prop1.oclIsTypeOf(MyType)
>> and self.prop2.oclIsTypeOf(MyType) ..
>> and I want something like: inv:
>> self.prop1.oclIsTypeOf(self.prop2.getTheTypeOfThisProperties )
>>
>> Thanks in advance,
>>
>> Regards,
>> Sylvain
>

Hi Christian,

thanks for your response...maybe this fonctionnality will be defined for
ocl 3.xxx ;-)

Sylvain
Previous Topic:Re: Problem with Interactive OCL Console used with Sample Ecore Editor
Next Topic:OCL has moved in the CVS Repository
Goto Forum:
  


Current Time: Thu Sep 19 11:03:00 GMT 2024

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

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

Back to the top