Under the description of ParameterSet
in section 9.9.16 on p. 190, the diagrams mentioned (Features
and Behaviors
) show that ParameterSet
can be owned either by a BehavioralFeature
or by a Behavior
. However, the constraints under section 9.9.16.5 seem to assume that it will be owned by BehavioralFeature
?
For example:
• input
If a parameterized entity has input Parameters that are in a ParameterSet, then any inputs that are not in a
ParameterSet must be streaming. Same for output Parameters.
inv: ((parameter->exists(direction = ParameterDirectionKind::_'in')) implies
behavioralFeature.ownedParameter->select(p | p.direction = ParameterDirectionKind::_'in'
and p.parameterSet->isEmpty())->forAll(isStream))
and
((parameter->exists(direction = ParameterDirectionKind::out)) implies
behavioralFeature.ownedParameter->select(p | p.direction = ParameterDirectionKind::out
and p.parameterSet->isEmpty())->forAll(isStream))
Also, this particular constraint ignores the inout
and return
parameters. I couldn't find any reference that would prohibit such parameters from being elements of a ParameterSet
, although it is not clear to me how they would be used.
================
EDIT:
If I understand Axel's comment correctly, then the owner of ParameterSet
can still be either Behavior
or BehavioralFeature
, but the constraint would have to accomodate both. Here is my attempt at an OCL implementation:
inv: if behavioralFeature <> null then
((parameter->exists(direction = ParameterDirectionKind::_'in')) implies
behavioralFeature.ownedParameter->select(p | p.direction = ParameterDirectionKind::_'in'
and p.parameterSet->isEmpty())->forAll(isStream))
and
((parameter->exists(direction = ParameterDirectionKind::out)) implies
behavioralFeature.ownedParameter->select(p | p.direction = ParameterDirectionKind::out
and p.parameterSet->isEmpty())->forAll(isStream))
else
((parameter->exists(direction = ParameterDirectionKind::_'in')) implies
behavior.ownedParameter->select(p | p.direction = ParameterDirectionKind::_'in'
and p.parameterSet->isEmpty())->forAll(isStream))
and
((parameter->exists(direction = ParameterDirectionKind::out)) implies
behavior.ownedParameter->select(p | p.direction = ParameterDirectionKind::out
and p.parameterSet->isEmpty())->forAll(isStream))
endif
Would this be consistent with the UML intent?
As to the inout
and return
parameters, I suppose they just do not belong in a ParameterSet
. Ideally, there should be an additional constraint restricting the allowed parameter direction.
In the UML 2.4.1 it looked like this:
All the constraints didn't have a formal specification with OCL, but from the description and the diagram we see, that the intention was to treat both cases the same. I guess it was just forgotten to implement the case of behaviors. Also the input and output parameters are described informally. So, I think any input is meant by this, and this includes inout parameters and any output is meant including inout and return parameters.
So, your OCL needs to become even more complicated. You could save some space by declaring a variable ownedParameter
.