Home » Modeling » OCL » Preconditions and inheritance
Preconditions and inheritance [message #19988] |
Fri, 27 April 2007 05:02  |
Eclipse User |
|
|
|
Hello,
While in Java all objects automatically inherit the methods of their
superclass(es), in C++ you have to add the 'virtual' keyword.
If I have a class B that inherits from a class A which contains a method
'start'
context A::start():void pre
// ...
is no doubt a valid constraint.
But what about "context B::start():void" if start is not redefined in B ?
This would have a meaning in Java but not in C++ if start is not virtual.
Since OCL is language independent how should I handle this ?
I tried to do something like "context B::start():void pre..." without
success.
I'm using an Ecore model and inheritance works well for attributes.
Thanks for your help,
Youmm.
|
|
| | | |
Re: Preconditions and inheritance [message #39997 is a reply to message #20097] |
Mon, 08 October 2007 05:16   |
Eclipse User |
|
|
|
Hi,
I'm also facing this problem, but I can't find setEOperation() in OCLHelper,
but only setOperationContext(), and I have no idea what should I pass the
arguments.
For example, I defined operation "isValid()" in class A, class B inherits A,
how do I configure my OCLHelper to let expression "b.isValid()" work?
Regards,
Hao
"Christian W. Damus" <cdamus@ca.ibm.com>
??????:f0svu5$b9i$1@build.eclipse.org...
>
> Hi, Youmm,
>
> I see ... you were using the OCLHelper. Yes, in that case, you specify an
> EClass that is not the one that owns the EOperation, but rather inherits
> it. The same works for the attribute context.
>
> Cheers,
>
> Christian
>
>
> Youmm P. wrote:
>
>>
>>> What you are trying to do should work. In what way is it not? Is it
>>> not
>>> parsing?
>>>
>> Ok I think I get it : with OCLHelper you've got to use setEOperation
>> with the inherited class and with the method of one of the superclasses.
>>
>> Thanks for the explanations.
>
|
|
| | |
Re: Preconditions and inheritance [message #40088 is a reply to message #39997] |
Tue, 09 October 2007 10:20  |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Hao,
The arguments to the setOperationContext() method are "context" and
"operation." The first is the classifier context in which you want to
define this constraint and the second is the operation, which may be
defined by the context classifier or inherited by it.
So, doing
EClass a = ... ;
EOperation isValid = ... ;
EClass b = ... ;
OCLHelper<EClassifier, EOperation, ?, Constraint> helper = ... ;
helper.setOperationContext(b, isValid);
Constraint constraint = helper.createPrecondition(...);
is equivalent to this concrete syntax of the context declaration:
context B::isValid() : Boolean
pre: -- some OCL condition
assuming, of course, the A::isValid() has EBoolean or EBooleanObject type.
HTH,
Christian
Hao Zhang wrote:
> Hi,
>
> I'm also facing this problem, but I can't find setEOperation() in
> OCLHelper, but only setOperationContext(), and I have no idea what should
> I pass the arguments.
>
> For example, I defined operation "isValid()" in class A, class B inherits
> A, how do I configure my OCLHelper to let expression "b.isValid()" work?
>
> Regards,
> Hao
>
> "Christian W. Damus" <cdamus@ca.ibm.com>
> ??????:f0svu5$b9i$1@build.eclipse.org...
>>
>> Hi, Youmm,
>>
>> I see ... you were using the OCLHelper. Yes, in that case, you specify
>> an EClass that is not the one that owns the EOperation, but rather
>> inherits
>> it. The same works for the attribute context.
>>
>> Cheers,
>>
>> Christian
>>
>>
>> Youmm P. wrote:
>>
>>>
>>>> What you are trying to do should work. In what way is it not? Is it
>>>> not
>>>> parsing?
>>>>
>>> Ok I think I get it : with OCLHelper you've got to use setEOperation
>>> with the inherited class and with the method of one of the superclasses.
>>>
>>> Thanks for the explanations.
>>
|
|
|
Goto Forum:
Current Time: Tue May 20 05:29:52 EDT 2025
Powered by FUDForum. Page generated in 0.04761 seconds
|