On page 177 of the UML 2.5.1 specification under section 9.9.47 “Operations” for Classifier
, we have the following operation definitions:
directlyRealizedInterfaces() : Interface [0..*]
The Interfaces directly realized by this Classifier
body: (clientDependency->select(
oclIsKindOf(Realization)
and supplier->forAll(oclIsKindOf(Interface))))->
collect(supplier.oclAsType(Interface))->asSet()
This is fairly straightforward to implement, for example in C++, since there is a property clentDependency
defined for NamedElement
which is one of the base classes for Classifier
.
However, the next operation is problematic:
directlyUsedInterfaces() : Interface [0..*]
The Interfaces directly used by this Classifier
body: (supplierDependency->select(
oclIsKindOf(Usage)
and client->forAll(oclIsKindOf(Interface))))->
collect(client.oclAsType(Interface))->asSet()
The problem is that there is no property supplierDependency
in NamedElement
. Perhaps there used to be one and it was removed? I came across this reference WRT supplierDependency
: https://www.site.uottawa.ca/~tcl/gradtheses/mnojoumian/ThesisFiles/FinalSpec/UML/7.3.33.html
I suppose this could be implemented similar to the NamedElement::clientDependency()
body:
body: Dependency.allInstances()->select(d | d.client->includes(self))
using supplier
instead of client
?
supplierDependency is the opposite Dependency::supplier.
OCL applies at both analysis and at run-time.
At analysis time there is no fundamental problem in traversing all relationships in all directions. For relationships for which the author neglected to define an explicit opposite name there is a policy that allows the opposite class name to be used as the opposite and if that is ambiguous a fallback on a qualified navigation is available.
At run-time, the OCL implementation must provide a mechanism to navigate in the ‘wrong’ direction. Naively this may be done by a total model search for both ends of the ‘right’ direction. A smarter approach caches the first model search to avoid the cost on every navigation. An even smarter approach pre-analyses the suite of OCL expressions to identify which opposites (and allInstances) are actually used and populates caches during model loading, updating if necessary during model mutation.
There actually is a property supplierDependency
defined on NamedElement
as you can see in the UML specification
This is also present in the xmi file for version 2.5. This is an image of the resulting model in EA after importing the xmi file.
2