next up previous contents
Next: Iterators Up: Visitors Previous: CascadingMap   Contents


VisitorMap is declared in suifkernel/visitor_map.h. The VisitorMap is a special-purpose Visitor which dynamically dispatches a SuifObject and the address of state to one of several functions, depending on its type. Each function is of type VisitMethod:          typedef void *Address; // declared in iokernel/iokernel_forwarders.h
         typedef void (*VisitMethod)( Address state, Object *object );
The constructor takes a pointer to the SuifEnv, which is used to interact with the MetaClass system to determine the appropriate action. It has the following operations: Here is an example use:
       class MyVisitorInfo {
            static void do_static_procedure_definition( 
                             void *info,
                             ProcedureDefinition *obj) {
                (MyVisitorInfo *)info->do_procedure_definition(obj);
            void do_procedure_definition(ProcedureDefinition *proc_def) {
       // register the visitor functions
       VisitorMap *map = new VisitorMap(suif_env);
       MyVisitorClass my_info;
       map->registerVisitMethod( &myinfo, 
                                 ProcedureDefinition::get_class_name() );
       // Pick an object:
       SuifObject *so;

SUIF Nightly Build