mentor/derived/ShortestPathIE.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:50:48 PST 1995 by kalsow  
      modified on Sun Jun  5 21:59:57 PDT 1994 by mhb     
      modified on Wed Feb 17 16:46:47 PST 1993 by johnh   

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file ShortestPath.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE ShortestPathIE;

<*NOWARN*> IMPORT TextConv, ZeusClass, Zeus, Algorithm, View;
<*NOWARN*> IMPORT Thread, ShortestPathViewClass, AlgorithmClass;
<*NOWARN*> IMPORT ShortestPathAlgClass;

<* FATAL Zeus.Error, Zeus.Locked *>
If you get either of these errors, contact a Zeus implementor.

TYPE
  NewVertexArgs = BRANDED REF RECORD
    name: TEXT;
    x: REAL;
    y: REAL;
  END;

  NewEdgeArgs = BRANDED REF RECORD
    name: TEXT;
    from: TEXT;
    to: TEXT;
    orientation: TEXT;
  END;

  StartFindArgs = BRANDED REF RECORD
    from: TEXT;
    to: TEXT;
  END;

  PromoteArgs = BRANDED REF RECORD
    edge: TEXT;
    sIndex: INTEGER;
    dIndex: INTEGER;
  END;

  ConsiderArgs = BRANDED REF RECORD
    edge: TEXT;
    sIndex: INTEGER;
    dIndex: INTEGER;
  END;

  TracebackArgs = BRANDED REF RECORD
    edge: TEXT;
    sIndex: INTEGER;
    dIndex: INTEGER;
  END;
Zeus calls the following to invoke vbt v's event handler:

<*NOWARN*> PROCEDURE OEDispatcher(v: ZeusClass.T; evt: REFANY) RAISES {Thread.Alerted} =
  <* LL <= VBT.mu *>
  (* LL = {} if event style is output, LL = VBT.mu if event style is update. *)
  BEGIN
    TYPECASE v OF
    | ShortestPathViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | NewVertexArgs(varNewVertexArgs) => <*NOWARN*>
          view.oeNewVertex (
              varNewVertexArgs.name
                ,
              varNewVertexArgs.x
                ,
              varNewVertexArgs.y
              )
      | NewEdgeArgs(varNewEdgeArgs) => <*NOWARN*>
          view.oeNewEdge (
              varNewEdgeArgs.name
                ,
              varNewEdgeArgs.from
                ,
              varNewEdgeArgs.to
                ,
              varNewEdgeArgs.orientation
              )
      | StartFindArgs(varStartFindArgs) => <*NOWARN*>
          view.oeStartFind (
              varStartFindArgs.from
                ,
              varStartFindArgs.to
              )
      | PromoteArgs(varPromoteArgs) => <*NOWARN*>
          view.oePromote (
              varPromoteArgs.edge
                ,
              varPromoteArgs.sIndex
                ,
              varPromoteArgs.dIndex
              )
      | ConsiderArgs(varConsiderArgs) => <*NOWARN*>
          view.oeConsider (
              varConsiderArgs.edge
                ,
              varConsiderArgs.sIndex
                ,
              varConsiderArgs.dIndex
              )
      | TracebackArgs(varTracebackArgs) => <*NOWARN*>
          view.oeTraceback (
              varTracebackArgs.edge
                ,
              varTracebackArgs.sIndex
                ,
              varTracebackArgs.dIndex
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a ShortestPathViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | ShortestPathAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a ShortestPathAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE NewVertex (
      initiator: Algorithm.T;
       name: TEXT; x, y: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewVertexArgs
               , name := name
               , x := x
               , y := y
      );
      alg := NARROW(initiator, ShortestPathAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewVertex);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewVertex;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewVertex;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewVertex", OEDispatcher, zumeArgRec);
    END;
  END NewVertex;

PROCEDURE NewEdge (
      initiator: Algorithm.T;
       name, from, to, orientation: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewEdgeArgs
               , name := name
               , from := from
               , to := to
               , orientation := orientation
      );
      alg := NARROW(initiator, ShortestPathAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewEdge);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewEdge;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewEdge;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewEdge", OEDispatcher, zumeArgRec);
    END;
  END NewEdge;

PROCEDURE StartFind (
      initiator: Algorithm.T;
       from, to: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StartFindArgs
               , from := from
               , to := to
      );
      alg := NARROW(initiator, ShortestPathAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStartFind);
      alg.stopAtEvent := alg.eventDataRec.stopAtStartFind;
      alg.waitAtEvent := alg.eventDataRec.waitAtStartFind;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StartFind", OEDispatcher, zumeArgRec);
    END;
  END StartFind;

PROCEDURE Promote (
      initiator: Algorithm.T;
       edge: TEXT; sIndex, dIndex: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(PromoteArgs
               , edge := edge
               , sIndex := sIndex
               , dIndex := dIndex
      );
      alg := NARROW(initiator, ShortestPathAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfPromote);
      alg.stopAtEvent := alg.eventDataRec.stopAtPromote;
      alg.waitAtEvent := alg.eventDataRec.waitAtPromote;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Promote", OEDispatcher, zumeArgRec);
    END;
  END Promote;

PROCEDURE Consider (
      initiator: Algorithm.T;
       edge: TEXT; sIndex, dIndex: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ConsiderArgs
               , edge := edge
               , sIndex := sIndex
               , dIndex := dIndex
      );
      alg := NARROW(initiator, ShortestPathAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfConsider);
      alg.stopAtEvent := alg.eventDataRec.stopAtConsider;
      alg.waitAtEvent := alg.eventDataRec.waitAtConsider;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Consider", OEDispatcher, zumeArgRec);
    END;
  END Consider;

PROCEDURE Traceback (
      initiator: Algorithm.T;
       edge: TEXT; sIndex, dIndex: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(TracebackArgs
               , edge := edge
               , sIndex := sIndex
               , dIndex := dIndex
      );
      alg := NARROW(initiator, ShortestPathAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfTraceback);
      alg.stopAtEvent := alg.eventDataRec.stopAtTraceback;
      alg.waitAtEvent := alg.eventDataRec.waitAtTraceback;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Traceback", OEDispatcher, zumeArgRec);
    END;
  END Traceback;

BEGIN
END ShortestPathIE.

interface View is in: