next up previous contents
Next: CascadingMap Up: Programming with the SUIF Previous: Cloning   Contents


A Visitor takes a pointer to an object and does something depending on what ``kind'' of object it is (of which derived class of SuifObject it is an instance). The builder of a Visitor need not specify what to do for every conceivable kind of object; if a behavior is not assigned to the class of the object, then the most specific superclass's behavior is used instead.

In SUIF several kinds of Visitor are used internally, and are also available to users of the system. The CascadingMap<T> is a template class which associates data of type T with a class. The VisitorMap class applies a specified function to the provided object. In both cases, the dynamic dispatch is implemented using the internal MetaClass system, querying the object's MetaClass and determining the closest ancestor MetaClass with specified behavior. Most SUIF programmers need not be concerned with information at the MetaClass level.

David Heine