mentor/derived/MaxflowAlgClass.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:48:22 PST 1995 by kalsow  
      modified on Wed Feb 17 16:46:18 PST 1993 by johnh   
      modified on Thu Sep 24 10:59:20 PDT 1992 by mhb     

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

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


MODULE MaxflowAlgClass;

<*NOWARN*> IMPORT Rd, ZeusClass, R2, Fmt, Algorithm, MFGraph, Wr;
<*NOWARN*> IMPORT ZeusPanel, FormsVBT, Text, VBT, MFAlgs, GraphVBT;
<*NOWARN*> IMPORT MFViews, RefList, MFFmt, ZeusUtil;

<* PRAGMA LL *>
Fix any FormsVBT errors; don't handle exceptions for them.
<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
      OVERRIDES
        <* LL = VBT.mu *>
        init := MaxflowDefaultInit;
        snapshot := MaxflowDefaultSnapshot;
        restore := MaxflowDefaultRestore;
        updateEventCounts := MaxflowDefaultUpdateCts;
        feAddVertex := AddVertex;
        feAddEdge := AddEdge;
      END;

PROCEDURE MaxflowDefaultInit (v: T): Algorithm.T =
  <* LL = VBT.mu *>
  PROCEDURE Attach (id: TEXT; proc: FormsVBT.Proc) =
    BEGIN
      FormsVBT.AttachProc(v.eventData, id, proc, v);
    END Attach;
  BEGIN
    v.eventData := ZeusPanel.NewForm("MaxflowEventData.fv");
    Attach("stopatCodeEvents", MaxflowDoIt);
    Attach("waitatCodeEvents", MaxflowDoIt);
    Attach("eventCounts", MaxflowRefreshCts);
    Attach("stopAtSetup", MaxflowDoIt);
    Attach("waitAtSetup", MaxflowDoIt);
    Attach("stopAtHighlightPath", MaxflowDoIt);
    Attach("waitAtHighlightPath", MaxflowDoIt);
    Attach("stopAtIncFlow", MaxflowDoIt);
    Attach("waitAtIncFlow", MaxflowDoIt);
    Attach("stopAtDecFlow", MaxflowDoIt);
    Attach("waitAtDecFlow", MaxflowDoIt);
    Attach("stopAtShowEdge", MaxflowDoIt);
    Attach("waitAtShowEdge", MaxflowDoIt);
    Attach("stopAtRemoveHighlight", MaxflowDoIt);
    Attach("waitAtRemoveHighlight", MaxflowDoIt);
    Attach("stopAtFinalResult", MaxflowDoIt);
    Attach("waitAtFinalResult", MaxflowDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END MaxflowDefaultInit;

PROCEDURE MaxflowDoIt (           fv : FormsVBT.T;
                           e  : TEXT;
                           arg: REFANY;
                <*UNUSED*> t  : VBT.TimeStamp) =
  <* LL = VBT.mu *>
  BEGIN
    IF Text.Equal(e, "stopatCodeEvents") THEN
      NARROW(arg, T).stopatCodeEvents :=
          FormsVBT.GetBoolean(fv, "stopatCodeEvents");
    END;
    IF Text.Equal(e, "waitatCodeEvents") THEN
      NARROW(arg, T).waitatCodeEvents :=
          FormsVBT.GetInteger(fv, "waitatCodeEvents");
    END;
    IF Text.Equal(e, "stopAtSetup") THEN
      NARROW(arg, T).eventDataRec.stopAtSetup :=
          FormsVBT.GetBoolean(fv, "stopAtSetup");
    END;
    IF Text.Equal(e, "waitAtSetup") THEN
      NARROW(arg, T).eventDataRec.waitAtSetup :=
          FormsVBT.GetInteger(fv, "waitAtSetup");
    END;
    IF Text.Equal(e, "stopAtHighlightPath") THEN
      NARROW(arg, T).eventDataRec.stopAtHighlightPath :=
          FormsVBT.GetBoolean(fv, "stopAtHighlightPath");
    END;
    IF Text.Equal(e, "waitAtHighlightPath") THEN
      NARROW(arg, T).eventDataRec.waitAtHighlightPath :=
          FormsVBT.GetInteger(fv, "waitAtHighlightPath");
    END;
    IF Text.Equal(e, "stopAtIncFlow") THEN
      NARROW(arg, T).eventDataRec.stopAtIncFlow :=
          FormsVBT.GetBoolean(fv, "stopAtIncFlow");
    END;
    IF Text.Equal(e, "waitAtIncFlow") THEN
      NARROW(arg, T).eventDataRec.waitAtIncFlow :=
          FormsVBT.GetInteger(fv, "waitAtIncFlow");
    END;
    IF Text.Equal(e, "stopAtDecFlow") THEN
      NARROW(arg, T).eventDataRec.stopAtDecFlow :=
          FormsVBT.GetBoolean(fv, "stopAtDecFlow");
    END;
    IF Text.Equal(e, "waitAtDecFlow") THEN
      NARROW(arg, T).eventDataRec.waitAtDecFlow :=
          FormsVBT.GetInteger(fv, "waitAtDecFlow");
    END;
    IF Text.Equal(e, "stopAtShowEdge") THEN
      NARROW(arg, T).eventDataRec.stopAtShowEdge :=
          FormsVBT.GetBoolean(fv, "stopAtShowEdge");
    END;
    IF Text.Equal(e, "waitAtShowEdge") THEN
      NARROW(arg, T).eventDataRec.waitAtShowEdge :=
          FormsVBT.GetInteger(fv, "waitAtShowEdge");
    END;
    IF Text.Equal(e, "stopAtRemoveHighlight") THEN
      NARROW(arg, T).eventDataRec.stopAtRemoveHighlight :=
          FormsVBT.GetBoolean(fv, "stopAtRemoveHighlight");
    END;
    IF Text.Equal(e, "waitAtRemoveHighlight") THEN
      NARROW(arg, T).eventDataRec.waitAtRemoveHighlight :=
          FormsVBT.GetInteger(fv, "waitAtRemoveHighlight");
    END;
    IF Text.Equal(e, "stopAtFinalResult") THEN
      NARROW(arg, T).eventDataRec.stopAtFinalResult :=
          FormsVBT.GetBoolean(fv, "stopAtFinalResult");
    END;
    IF Text.Equal(e, "waitAtFinalResult") THEN
      NARROW(arg, T).eventDataRec.waitAtFinalResult :=
          FormsVBT.GetInteger(fv, "waitAtFinalResult");
    END;
  END MaxflowDoIt;

PROCEDURE MaxflowRefreshCts (
                <*UNUSED*> fv  : FormsVBT.T;
                <*UNUSED*> e   : TEXT;
                           arg : REFANY;
                <*UNUSED*> t   : VBT.TimeStamp) =
  <* LL = VBT.mu *>
  BEGIN
    NARROW(arg, T).updateEventCounts(FALSE);
  END MaxflowRefreshCts;

PROCEDURE FromFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    alg.stopatCodeEvents :=
        FormsVBT.GetBoolean(fv, "stopatCodeEvents");
    alg.waitatCodeEvents :=
        FormsVBT.GetInteger(fv, "waitatCodeEvents");
    alg.eventDataRec.stopAtSetup :=
        FormsVBT.GetBoolean(fv, "stopAtSetup");
    alg.eventDataRec.waitAtSetup :=
        FormsVBT.GetInteger(fv, "waitAtSetup");
    alg.eventDataRec.stopAtHighlightPath :=
        FormsVBT.GetBoolean(fv, "stopAtHighlightPath");
    alg.eventDataRec.waitAtHighlightPath :=
        FormsVBT.GetInteger(fv, "waitAtHighlightPath");
    alg.eventDataRec.stopAtIncFlow :=
        FormsVBT.GetBoolean(fv, "stopAtIncFlow");
    alg.eventDataRec.waitAtIncFlow :=
        FormsVBT.GetInteger(fv, "waitAtIncFlow");
    alg.eventDataRec.stopAtDecFlow :=
        FormsVBT.GetBoolean(fv, "stopAtDecFlow");
    alg.eventDataRec.waitAtDecFlow :=
        FormsVBT.GetInteger(fv, "waitAtDecFlow");
    alg.eventDataRec.stopAtShowEdge :=
        FormsVBT.GetBoolean(fv, "stopAtShowEdge");
    alg.eventDataRec.waitAtShowEdge :=
        FormsVBT.GetInteger(fv, "waitAtShowEdge");
    alg.eventDataRec.stopAtRemoveHighlight :=
        FormsVBT.GetBoolean(fv, "stopAtRemoveHighlight");
    alg.eventDataRec.waitAtRemoveHighlight :=
        FormsVBT.GetInteger(fv, "waitAtRemoveHighlight");
    alg.eventDataRec.stopAtFinalResult :=
        FormsVBT.GetBoolean(fv, "stopAtFinalResult");
    alg.eventDataRec.waitAtFinalResult :=
        FormsVBT.GetInteger(fv, "waitAtFinalResult");
  END FromFV;

<*UNUSED*>
PROCEDURE ToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutBoolean(fv, "stopatCodeEvents", alg.stopatCodeEvents);
    FormsVBT.PutInteger(fv, "waitatCodeEvents", alg.waitatCodeEvents);
    FormsVBT.PutBoolean(fv, "stopAtSetup",
                        alg.eventDataRec.stopAtSetup);
    FormsVBT.PutInteger(fv, "waitAtSetup",
                        alg.eventDataRec.waitAtSetup);
    FormsVBT.PutBoolean(fv, "stopAtHighlightPath",
                        alg.eventDataRec.stopAtHighlightPath);
    FormsVBT.PutInteger(fv, "waitAtHighlightPath",
                        alg.eventDataRec.waitAtHighlightPath);
    FormsVBT.PutBoolean(fv, "stopAtIncFlow",
                        alg.eventDataRec.stopAtIncFlow);
    FormsVBT.PutInteger(fv, "waitAtIncFlow",
                        alg.eventDataRec.waitAtIncFlow);
    FormsVBT.PutBoolean(fv, "stopAtDecFlow",
                        alg.eventDataRec.stopAtDecFlow);
    FormsVBT.PutInteger(fv, "waitAtDecFlow",
                        alg.eventDataRec.waitAtDecFlow);
    FormsVBT.PutBoolean(fv, "stopAtShowEdge",
                        alg.eventDataRec.stopAtShowEdge);
    FormsVBT.PutInteger(fv, "waitAtShowEdge",
                        alg.eventDataRec.waitAtShowEdge);
    FormsVBT.PutBoolean(fv, "stopAtRemoveHighlight",
                        alg.eventDataRec.stopAtRemoveHighlight);
    FormsVBT.PutInteger(fv, "waitAtRemoveHighlight",
                        alg.eventDataRec.waitAtRemoveHighlight);
    FormsVBT.PutBoolean(fv, "stopAtFinalResult",
                        alg.eventDataRec.stopAtFinalResult);
    FormsVBT.PutInteger(fv, "waitAtFinalResult",
                        alg.eventDataRec.waitAtFinalResult);
    CountsToFV (fv, alg);
  END ToFV;

PROCEDURE CountsToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutText(fv, "ctOfSetup",
                        Fmt.Int(alg.eventDataRec.ctOfSetup));
    FormsVBT.PutText(fv, "ctOfHighlightPath",
                        Fmt.Int(alg.eventDataRec.ctOfHighlightPath));
    FormsVBT.PutText(fv, "ctOfIncFlow",
                        Fmt.Int(alg.eventDataRec.ctOfIncFlow));
    FormsVBT.PutText(fv, "ctOfDecFlow",
                        Fmt.Int(alg.eventDataRec.ctOfDecFlow));
    FormsVBT.PutText(fv, "ctOfShowEdge",
                        Fmt.Int(alg.eventDataRec.ctOfShowEdge));
    FormsVBT.PutText(fv, "ctOfRemoveHighlight",
                        Fmt.Int(alg.eventDataRec.ctOfRemoveHighlight));
    FormsVBT.PutText(fv, "ctOfFinalResult",
                        Fmt.Int(alg.eventDataRec.ctOfFinalResult));
  END CountsToFV;

PROCEDURE MaxflowDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfSetup := 0;
      v.eventDataRec.ctOfHighlightPath := 0;
      v.eventDataRec.ctOfIncFlow := 0;
      v.eventDataRec.ctOfDecFlow := 0;
      v.eventDataRec.ctOfShowEdge := 0;
      v.eventDataRec.ctOfRemoveHighlight := 0;
      v.eventDataRec.ctOfFinalResult := 0;
    END;
    CountsToFV (v.eventData, v);
  END MaxflowDefaultUpdateCts;

PROCEDURE MaxflowDefaultSnapshot (v: T; wr: Wr.T)
  RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TRY
      Wr.PutChar(wr, '(')
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "MaxflowAlgClass.MaxflowDefaultSnapshot write error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "MaxflowAlgClass.MaxflowDefaultSnapshot: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.snapshot(wr)
    EXCEPT
      FormsVBT.Error (msg) =>
        RAISE ZeusClass.Error(
          "MaxflowAlgClass.MaxflowDefaultSnapshot FV error: "
          & msg);
    ELSE
      RAISE ZeusClass.Error(
        "MaxflowAlgClass.MaxflowDefaultSnapshot error");
    END;
    Algorithm.T.snapshot(v, wr);
    TRY
      Wr.PutChar(wr, ')')
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "MaxflowAlgClass.MaxflowDefaultSnapshot write error");
    END;
  END MaxflowDefaultSnapshot;

PROCEDURE MaxflowDefaultRestore (v: T; rd: Rd.T)
  RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    IF rd = NIL THEN RETURN END;
    IF NOT ZeusUtil.EatChar(rd, '(') THEN
      RAISE ZeusClass.Error(
          "MaxflowAlgClass.MaxflowDefaultRestore read error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "MaxflowAlgClass.MaxflowDefaultRestore: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.restore(rd);
      v.updateEventCounts(FALSE);
      FromFV(v.eventData, v);
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "MaxflowAlgClass.MaxflowDefaultRestore error");
    END;
    Algorithm.T.restore(v, rd);
    IF NOT ZeusUtil.EatChar(rd, ')') THEN
      RAISE ZeusClass.Error(
          "MaxflowAlgClass.MaxflowDefaultRestore read error");
    END;
  END MaxflowDefaultRestore;

PROCEDURE AddVertex (self: T
    ; <*UNUSED*> pos: R2.T
) =
  <* LL = VBT.mu *>
  BEGIN
    self.evtHandled := FALSE;
  END AddVertex;

PROCEDURE AddEdge (self: T
    ; <*UNUSED*> v0: MFGraph.Vertex
    ; <*UNUSED*> v1: MFGraph.Vertex
) =
  <* LL = VBT.mu *>
  BEGIN
    self.evtHandled := FALSE;
  END AddEdge;

BEGIN
END MaxflowAlgClass.

interface GraphVBT is in: