OCL: how to constraints two properties to have the same type ? [message #1013] |
Tue, 23 January 2007 05:45  |
Eclipse User |
|
|
|
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 #1069 is a reply to message #1041] |
Tue, 23 January 2007 11:22  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03759 seconds