|
Traverse the class structure to find all connected objects. An explicit path from the source class to targets doesn't have to be specified.
See also: the Demeter Project ( http://www.ccs.neu.edu/research/demeter/ )
Name of the method that should be called on the connected objects. If not set, remoteOperation is the same as operation (implement, single) .
Used to restrict the possible paths from the source to the target object. avoidingRelations is a set of relations that should not be traversed.
Used to restrict the possible paths from the source to the target object. avoidingRelations is a set of relations that have to be traversed.
Used to restrict the possible paths from the source to the target
object. avoidingClasses is
a set of objecttypes (classes) that should not be traversed.
Used to restrict the possible paths from the source to the target
object. avoidingClasses is
a set of objecttypes (classes) that have to be traversed.
Follow bidirecctional relations only in one direction. Set this parameter to false if relations should be traversed in both ways e.g. to find all neighbouring rooms of one room if neighbor is a n:m relation from Room to itself.
If set to true, Traversal collects all objects in a set and calls the operation ony once for each connected object. Otherwise, if one object is connected via multiple relations, the operation is called for each connection.
The name of an optional parameter that should be passed along.
bind: 'target' to: 'Room'; bind: 'operation' to: 'printAll'; bind: 'remoteOperation' to: 'print'; bind: 'relation' to: '#(#LeftWalls #controlOfRoom)'.
This example will generate a method printAll which will call a print method on all connected LeftWalls and Controls. The Pattern takes care of the cardinality of the relations. The generated method in Smalltalk might look like this:
"follow all relations." "1:n relation." self LeftWalls connections do: [ :anObject| anObject print ]. "1:1 relation." self controlOfRoom instance notNil ifTrue: [ self controlOfRoom instance print ].
The Pattern uses code synthesis techniques to generate its code. Depending on the "unique " paramter, the Pattern FollowRelation (unique = false) or FollowRelationAndCollectObjects is dynamically (during the generation) aggregated for each relation that should be traversed. Additionally the Pattern MethodCall is aggregated once to call the generated follow methods.
FollowRelation , FollowRelationAndCollectObjects , MethodCall .
Pattern Traversal Category indirection ObjectType use from ObjectType use to SingleMethod implement operation SingleMethod use optional remoteOperation at to Expression implement optional avoidingRelations Expression implement optional usingRelations Expression implement optional avoidingClasses Expression implement optional usingClasses Expression implement preset oneWay Expression implement preset unique Expression implement optional parameter End