| Single OCL constraint for multiple properties [message #517163] |
Fri, 26 February 2010 07:49  |
Timothy Marc Messages: 547 Registered: July 2009 |
Senior Member |
|
|
Hi all,
i've a question concerning OCL for properties contained in different
classifiers. Let's assume, we have two signals:
Signal A {xyz:Integer}
Signal B {xyz:Integer}
Both properties are restricted by the same kind of constraint. In OCL i
would use the following syntax:
context A
inv: self.xyz > 0
context B
inv: self.xyz > 0
Since we have a lot of Signals, sharing similar properties, it is a
quite annoying and repitive task to define these constraints in each
signal separately. I know, generaliaztion might be the answer, but we
didn't want the signals to be compatible with each other.
In UML it is possible to define a constraint somewhere in the model and
refer to elements which will be constrained by this single constraint.
Is this also possible with OCL? If so, how does the syntax look like?
Would the constraint point to the signals and than just state the
invariant like this:
self.xyz > 0
Cheers and Thanks
Timothy
|
|
|