Java Reference
In-Depth Information
Visitor Cycles
The ProcessComponent hierarchy that Oozinoz uses to model process flows is another
composite structure that can benefit from building in support for V ISITOR . Unlike machine
composites, it is natural for process flows to contain cycles, and visitors must take care not to
cause infinite loops while traversing process composites. Figure 29.5 shows
the ProcessComponent hierarchy.
Figure 29.5. Like the MachineComponent hierarchy, the ProcessComponent hierarchy
can build in support for Visitor.
Suppose that you want to print out a process component in a "pretty," or indented, format. In
Chapter 28, Iterator, you used an iterator to print out a process flow's steps. This printout
looked like:
Make an aerial shell
Build inner shell
Inspect
Rework inner shell, or complete shell
Rework
Disassemble
Finish: Attach lift, insert fusing, wrap
You may recall that the step after " Disassemble " is " Make an aerial shell ." The
printout doesn't show this step, because the iterator sees that the step has already appeared
once. However, it would be more informative to show the step name and to indicate that the
process enters a cycle at this point. It would also be helpful to indicate which composites are
alternations as opposed to sequences.
Search WWH ::




Custom Search