mentor/derived/MaxflowIE.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 Maxflow.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE MaxflowIE;

<*NOWARN*> IMPORT MaxflowAlgClass, Zeus, ZeusClass, R2, Algorithm;
<*NOWARN*> IMPORT MFGraph, Thread, View, MaxflowViewClass, MFAlgs;
<*NOWARN*> IMPORT AlgorithmClass, GraphVBT, MFViews, RefList;
<*NOWARN*> IMPORT MFFmt;

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

TYPE
  SetupArgs = BRANDED REF RECORD
    g: MFGraph.T;
    source: MFGraph.Vertex;
    sink: MFGraph.Vertex;
  END;

  HighlightPathArgs = BRANDED REF RECORD
    path: RefList.T;
    maxCapacity: REAL;
  END;

  IncFlowArgs = BRANDED REF RECORD
    edge: MFGraph.Edge;
    flow: REAL;
    number: CARDINAL;
    maxCapacity: REAL;
    capa: REAL;
  END;

  DecFlowArgs = BRANDED REF RECORD
    edge: MFGraph.Edge;
    oldflow: REAL;
    newflow: REAL;
    number: CARDINAL;
    maxCapacity: REAL;
    capa: REAL;
  END;

  ShowEdgeArgs = BRANDED REF RECORD
    number: CARDINAL;
    typeOfEdge: CARDINAL;
  END;

  RemoveHighlightArgs = BRANDED REF RECORD
    sinkvertex: MFGraph.Vertex;
  END;

  FinalResultArgs = BRANDED REF RECORD
    b: BOOLEAN;
  END;

  AddVBTVertexArgs = BRANDED REF RECORD
    v: MFAlgs.MFVertex;
    pos: R2.T;
    label: TEXT;
  END;

  AddVBTEdgeArgs = BRANDED REF RECORD
    e: MFAlgs.MFEdge;
  END;

  AddVertexArgs = BRANDED REF RECORD
    pos: R2.T;
  END;

  AddEdgeArgs = BRANDED REF RECORD
    v0: MFGraph.Vertex;
    v1: MFGraph.Vertex;
  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
    | MaxflowViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | SetupArgs(varSetupArgs) => <*NOWARN*>
          view.oeSetup (
              varSetupArgs.g
                ,
              varSetupArgs.source
                ,
              varSetupArgs.sink
              )
      | HighlightPathArgs(varHighlightPathArgs) => <*NOWARN*>
          view.oeHighlightPath (
              varHighlightPathArgs.path
                ,
              varHighlightPathArgs.maxCapacity
              )
      | IncFlowArgs(varIncFlowArgs) => <*NOWARN*>
          view.oeIncFlow (
              varIncFlowArgs.edge
                ,
              varIncFlowArgs.flow
                ,
              varIncFlowArgs.number
                ,
              varIncFlowArgs.maxCapacity
                ,
              varIncFlowArgs.capa
              )
      | DecFlowArgs(varDecFlowArgs) => <*NOWARN*>
          view.oeDecFlow (
              varDecFlowArgs.edge
                ,
              varDecFlowArgs.oldflow
                ,
              varDecFlowArgs.newflow
                ,
              varDecFlowArgs.number
                ,
              varDecFlowArgs.maxCapacity
                ,
              varDecFlowArgs.capa
              )
      | ShowEdgeArgs(varShowEdgeArgs) => <*NOWARN*>
          view.oeShowEdge (
              varShowEdgeArgs.number
                ,
              varShowEdgeArgs.typeOfEdge
              )
      | RemoveHighlightArgs(varRemoveHighlightArgs) => <*NOWARN*>
          view.oeRemoveHighlight (
              varRemoveHighlightArgs.sinkvertex
              )
      | FinalResultArgs(varFinalResultArgs) => <*NOWARN*>
          view.oeFinalResult (
              varFinalResultArgs.b
              )
      | AddVBTVertexArgs(varAddVBTVertexArgs) => <*NOWARN*>
          view.ueAddVBTVertex (
              varAddVBTVertexArgs.v
                ,
              varAddVBTVertexArgs.pos
                ,
              varAddVBTVertexArgs.label
              )
      | AddVBTEdgeArgs(varAddVBTEdgeArgs) => <*NOWARN*>
          view.ueAddVBTEdge (
              varAddVBTEdgeArgs.e
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a MaxflowViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | MaxflowAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      | AddVertexArgs(varAddVertexArgs) => <*NOWARN*>
          alg.feAddVertex (
              varAddVertexArgs.pos
              )
      | AddEdgeArgs(varAddEdgeArgs) => <*NOWARN*>
          alg.feAddEdge (
              varAddEdgeArgs.v0
                ,
              varAddEdgeArgs.v1
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a MaxflowAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE Setup (
      initiator: Algorithm.T;
       g: MFGraph.T; source: MFGraph.Vertex; sink: MFGraph.Vertex
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupArgs
               , g := g
               , source := source
               , sink := sink
      );
      alg := NARROW(initiator, MaxflowAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetup);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetup;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetup;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Setup", OEDispatcher, zumeArgRec);
    END;
  END Setup;

PROCEDURE HighlightPath (
      initiator: Algorithm.T;
       path: RefList.T; maxCapacity: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(HighlightPathArgs
               , path := path
               , maxCapacity := maxCapacity
      );
      alg := NARROW(initiator, MaxflowAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfHighlightPath);
      alg.stopAtEvent := alg.eventDataRec.stopAtHighlightPath;
      alg.waitAtEvent := alg.eventDataRec.waitAtHighlightPath;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "HighlightPath", OEDispatcher, zumeArgRec);
    END;
  END HighlightPath;

PROCEDURE IncFlow (
      initiator: Algorithm.T;
       edge: MFGraph.Edge; flow: REAL; number: CARDINAL; maxCapacity: REAL; capa: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(IncFlowArgs
               , edge := edge
               , flow := flow
               , number := number
               , maxCapacity := maxCapacity
               , capa := capa
      );
      alg := NARROW(initiator, MaxflowAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfIncFlow);
      alg.stopAtEvent := alg.eventDataRec.stopAtIncFlow;
      alg.waitAtEvent := alg.eventDataRec.waitAtIncFlow;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "IncFlow", OEDispatcher, zumeArgRec);
    END;
  END IncFlow;

PROCEDURE DecFlow (
      initiator: Algorithm.T;
       edge: MFGraph.Edge; oldflow: REAL; newflow: REAL; number: CARDINAL; maxCapacity: REAL; capa: REAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(DecFlowArgs
               , edge := edge
               , oldflow := oldflow
               , newflow := newflow
               , number := number
               , maxCapacity := maxCapacity
               , capa := capa
      );
      alg := NARROW(initiator, MaxflowAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfDecFlow);
      alg.stopAtEvent := alg.eventDataRec.stopAtDecFlow;
      alg.waitAtEvent := alg.eventDataRec.waitAtDecFlow;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "DecFlow", OEDispatcher, zumeArgRec);
    END;
  END DecFlow;

PROCEDURE ShowEdge (
      initiator: Algorithm.T;
       number, typeOfEdge: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ShowEdgeArgs
               , number := number
               , typeOfEdge := typeOfEdge
      );
      alg := NARROW(initiator, MaxflowAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfShowEdge);
      alg.stopAtEvent := alg.eventDataRec.stopAtShowEdge;
      alg.waitAtEvent := alg.eventDataRec.waitAtShowEdge;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "ShowEdge", OEDispatcher, zumeArgRec);
    END;
  END ShowEdge;

PROCEDURE RemoveHighlight (
      initiator: Algorithm.T;
       sinkvertex: MFGraph.Vertex
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(RemoveHighlightArgs
               , sinkvertex := sinkvertex
      );
      alg := NARROW(initiator, MaxflowAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfRemoveHighlight);
      alg.stopAtEvent := alg.eventDataRec.stopAtRemoveHighlight;
      alg.waitAtEvent := alg.eventDataRec.waitAtRemoveHighlight;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "RemoveHighlight", OEDispatcher, zumeArgRec);
    END;
  END RemoveHighlight;

PROCEDURE FinalResult (
      initiator: Algorithm.T;
       b: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(FinalResultArgs
               , b := b
      );
      alg := NARROW(initiator, MaxflowAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfFinalResult);
      alg.stopAtEvent := alg.eventDataRec.stopAtFinalResult;
      alg.waitAtEvent := alg.eventDataRec.waitAtFinalResult;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "FinalResult", OEDispatcher, zumeArgRec);
    END;
  END FinalResult;

PROCEDURE AddVBTVertex (
      initiator: Algorithm.T;
       v: MFAlgs.MFVertex; pos: R2.T; label: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(AddVBTVertexArgs
               , v := v
               , pos := pos
               , label := label
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Update, 1,
                  "AddVBTVertex", OEDispatcher, zumeArgRec);
  END AddVBTVertex;

PROCEDURE AddVBTEdge (
      initiator: Algorithm.T;
       e: MFAlgs.MFEdge
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(AddVBTEdgeArgs
               , e := e
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Update, 1,
                  "AddVBTEdge", OEDispatcher, zumeArgRec);
  END AddVBTEdge;

PROCEDURE AddVertex (
      initiator: View.T;
       pos: R2.T
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(AddVertexArgs
               , pos := pos
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Notify, 1,
                  "AddVertex", FEDispatcher, zumeArgRec);
  END AddVertex;

PROCEDURE AddEdge (
      initiator: View.T;
       v0: MFGraph.Vertex; v1: MFGraph.Vertex
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(AddEdgeArgs
               , v0 := v0
               , v1 := v1
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Notify, 1,
                  "AddEdge", FEDispatcher, zumeArgRec);
  END AddEdge;

BEGIN
END MaxflowIE.

interface View is in:


interface GraphVBT is in: