mentor/derived/DGraphAlgClass.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 DGraph.evt.
      ********************************************************************


MODULE DGraphAlgClass;

<*NOWARN*> IMPORT AdjMatrix, Rd, ZeusClass, Fmt, Algorithm, Wr;
<*NOWARN*> IMPORT ZeusPanel, FormsVBT, VBT, Text, 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 := DGraphDefaultInit;
        snapshot := DGraphDefaultSnapshot;
        restore := DGraphDefaultRestore;
        updateEventCounts := DGraphDefaultUpdateCts;
      END;

PROCEDURE DGraphDefaultInit (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("DGraphEventData.fv");
    Attach("stopatCodeEvents", DGraphDoIt);
    Attach("waitatCodeEvents", DGraphDoIt);
    Attach("eventCounts", DGraphRefreshCts);
    Attach("stopAtSetup", DGraphDoIt);
    Attach("waitAtSetup", DGraphDoIt);
    Attach("stopAtAddEdge", DGraphDoIt);
    Attach("waitAtAddEdge", DGraphDoIt);
    Attach("stopAtMarkEdge", DGraphDoIt);
    Attach("waitAtMarkEdge", DGraphDoIt);
    Attach("stopAtUnMarkEdge", DGraphDoIt);
    Attach("waitAtUnMarkEdge", DGraphDoIt);
    Attach("stopAtMarkVertex", DGraphDoIt);
    Attach("waitAtMarkVertex", DGraphDoIt);
    Attach("stopAtUnMarkVertex", DGraphDoIt);
    Attach("waitAtUnMarkVertex", DGraphDoIt);
    Attach("stopAtNewTree", DGraphDoIt);
    Attach("waitAtNewTree", DGraphDoIt);
    Attach("stopAtHighlight", DGraphDoIt);
    Attach("waitAtHighlight", DGraphDoIt);
    Attach("stopAtAddChild", DGraphDoIt);
    Attach("waitAtAddChild", DGraphDoIt);
    Attach("stopAtRemoveChild", DGraphDoIt);
    Attach("waitAtRemoveChild", DGraphDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END DGraphDefaultInit;

PROCEDURE DGraphDoIt (           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, "stopAtAddEdge") THEN
      NARROW(arg, T).eventDataRec.stopAtAddEdge :=
          FormsVBT.GetBoolean(fv, "stopAtAddEdge");
    END;
    IF Text.Equal(e, "waitAtAddEdge") THEN
      NARROW(arg, T).eventDataRec.waitAtAddEdge :=
          FormsVBT.GetInteger(fv, "waitAtAddEdge");
    END;
    IF Text.Equal(e, "stopAtMarkEdge") THEN
      NARROW(arg, T).eventDataRec.stopAtMarkEdge :=
          FormsVBT.GetBoolean(fv, "stopAtMarkEdge");
    END;
    IF Text.Equal(e, "waitAtMarkEdge") THEN
      NARROW(arg, T).eventDataRec.waitAtMarkEdge :=
          FormsVBT.GetInteger(fv, "waitAtMarkEdge");
    END;
    IF Text.Equal(e, "stopAtUnMarkEdge") THEN
      NARROW(arg, T).eventDataRec.stopAtUnMarkEdge :=
          FormsVBT.GetBoolean(fv, "stopAtUnMarkEdge");
    END;
    IF Text.Equal(e, "waitAtUnMarkEdge") THEN
      NARROW(arg, T).eventDataRec.waitAtUnMarkEdge :=
          FormsVBT.GetInteger(fv, "waitAtUnMarkEdge");
    END;
    IF Text.Equal(e, "stopAtMarkVertex") THEN
      NARROW(arg, T).eventDataRec.stopAtMarkVertex :=
          FormsVBT.GetBoolean(fv, "stopAtMarkVertex");
    END;
    IF Text.Equal(e, "waitAtMarkVertex") THEN
      NARROW(arg, T).eventDataRec.waitAtMarkVertex :=
          FormsVBT.GetInteger(fv, "waitAtMarkVertex");
    END;
    IF Text.Equal(e, "stopAtUnMarkVertex") THEN
      NARROW(arg, T).eventDataRec.stopAtUnMarkVertex :=
          FormsVBT.GetBoolean(fv, "stopAtUnMarkVertex");
    END;
    IF Text.Equal(e, "waitAtUnMarkVertex") THEN
      NARROW(arg, T).eventDataRec.waitAtUnMarkVertex :=
          FormsVBT.GetInteger(fv, "waitAtUnMarkVertex");
    END;
    IF Text.Equal(e, "stopAtNewTree") THEN
      NARROW(arg, T).eventDataRec.stopAtNewTree :=
          FormsVBT.GetBoolean(fv, "stopAtNewTree");
    END;
    IF Text.Equal(e, "waitAtNewTree") THEN
      NARROW(arg, T).eventDataRec.waitAtNewTree :=
          FormsVBT.GetInteger(fv, "waitAtNewTree");
    END;
    IF Text.Equal(e, "stopAtHighlight") THEN
      NARROW(arg, T).eventDataRec.stopAtHighlight :=
          FormsVBT.GetBoolean(fv, "stopAtHighlight");
    END;
    IF Text.Equal(e, "waitAtHighlight") THEN
      NARROW(arg, T).eventDataRec.waitAtHighlight :=
          FormsVBT.GetInteger(fv, "waitAtHighlight");
    END;
    IF Text.Equal(e, "stopAtAddChild") THEN
      NARROW(arg, T).eventDataRec.stopAtAddChild :=
          FormsVBT.GetBoolean(fv, "stopAtAddChild");
    END;
    IF Text.Equal(e, "waitAtAddChild") THEN
      NARROW(arg, T).eventDataRec.waitAtAddChild :=
          FormsVBT.GetInteger(fv, "waitAtAddChild");
    END;
    IF Text.Equal(e, "stopAtRemoveChild") THEN
      NARROW(arg, T).eventDataRec.stopAtRemoveChild :=
          FormsVBT.GetBoolean(fv, "stopAtRemoveChild");
    END;
    IF Text.Equal(e, "waitAtRemoveChild") THEN
      NARROW(arg, T).eventDataRec.waitAtRemoveChild :=
          FormsVBT.GetInteger(fv, "waitAtRemoveChild");
    END;
  END DGraphDoIt;

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

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.stopAtAddEdge :=
        FormsVBT.GetBoolean(fv, "stopAtAddEdge");
    alg.eventDataRec.waitAtAddEdge :=
        FormsVBT.GetInteger(fv, "waitAtAddEdge");
    alg.eventDataRec.stopAtMarkEdge :=
        FormsVBT.GetBoolean(fv, "stopAtMarkEdge");
    alg.eventDataRec.waitAtMarkEdge :=
        FormsVBT.GetInteger(fv, "waitAtMarkEdge");
    alg.eventDataRec.stopAtUnMarkEdge :=
        FormsVBT.GetBoolean(fv, "stopAtUnMarkEdge");
    alg.eventDataRec.waitAtUnMarkEdge :=
        FormsVBT.GetInteger(fv, "waitAtUnMarkEdge");
    alg.eventDataRec.stopAtMarkVertex :=
        FormsVBT.GetBoolean(fv, "stopAtMarkVertex");
    alg.eventDataRec.waitAtMarkVertex :=
        FormsVBT.GetInteger(fv, "waitAtMarkVertex");
    alg.eventDataRec.stopAtUnMarkVertex :=
        FormsVBT.GetBoolean(fv, "stopAtUnMarkVertex");
    alg.eventDataRec.waitAtUnMarkVertex :=
        FormsVBT.GetInteger(fv, "waitAtUnMarkVertex");
    alg.eventDataRec.stopAtNewTree :=
        FormsVBT.GetBoolean(fv, "stopAtNewTree");
    alg.eventDataRec.waitAtNewTree :=
        FormsVBT.GetInteger(fv, "waitAtNewTree");
    alg.eventDataRec.stopAtHighlight :=
        FormsVBT.GetBoolean(fv, "stopAtHighlight");
    alg.eventDataRec.waitAtHighlight :=
        FormsVBT.GetInteger(fv, "waitAtHighlight");
    alg.eventDataRec.stopAtAddChild :=
        FormsVBT.GetBoolean(fv, "stopAtAddChild");
    alg.eventDataRec.waitAtAddChild :=
        FormsVBT.GetInteger(fv, "waitAtAddChild");
    alg.eventDataRec.stopAtRemoveChild :=
        FormsVBT.GetBoolean(fv, "stopAtRemoveChild");
    alg.eventDataRec.waitAtRemoveChild :=
        FormsVBT.GetInteger(fv, "waitAtRemoveChild");
  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, "stopAtAddEdge",
                        alg.eventDataRec.stopAtAddEdge);
    FormsVBT.PutInteger(fv, "waitAtAddEdge",
                        alg.eventDataRec.waitAtAddEdge);
    FormsVBT.PutBoolean(fv, "stopAtMarkEdge",
                        alg.eventDataRec.stopAtMarkEdge);
    FormsVBT.PutInteger(fv, "waitAtMarkEdge",
                        alg.eventDataRec.waitAtMarkEdge);
    FormsVBT.PutBoolean(fv, "stopAtUnMarkEdge",
                        alg.eventDataRec.stopAtUnMarkEdge);
    FormsVBT.PutInteger(fv, "waitAtUnMarkEdge",
                        alg.eventDataRec.waitAtUnMarkEdge);
    FormsVBT.PutBoolean(fv, "stopAtMarkVertex",
                        alg.eventDataRec.stopAtMarkVertex);
    FormsVBT.PutInteger(fv, "waitAtMarkVertex",
                        alg.eventDataRec.waitAtMarkVertex);
    FormsVBT.PutBoolean(fv, "stopAtUnMarkVertex",
                        alg.eventDataRec.stopAtUnMarkVertex);
    FormsVBT.PutInteger(fv, "waitAtUnMarkVertex",
                        alg.eventDataRec.waitAtUnMarkVertex);
    FormsVBT.PutBoolean(fv, "stopAtNewTree",
                        alg.eventDataRec.stopAtNewTree);
    FormsVBT.PutInteger(fv, "waitAtNewTree",
                        alg.eventDataRec.waitAtNewTree);
    FormsVBT.PutBoolean(fv, "stopAtHighlight",
                        alg.eventDataRec.stopAtHighlight);
    FormsVBT.PutInteger(fv, "waitAtHighlight",
                        alg.eventDataRec.waitAtHighlight);
    FormsVBT.PutBoolean(fv, "stopAtAddChild",
                        alg.eventDataRec.stopAtAddChild);
    FormsVBT.PutInteger(fv, "waitAtAddChild",
                        alg.eventDataRec.waitAtAddChild);
    FormsVBT.PutBoolean(fv, "stopAtRemoveChild",
                        alg.eventDataRec.stopAtRemoveChild);
    FormsVBT.PutInteger(fv, "waitAtRemoveChild",
                        alg.eventDataRec.waitAtRemoveChild);
    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, "ctOfAddEdge",
                        Fmt.Int(alg.eventDataRec.ctOfAddEdge));
    FormsVBT.PutText(fv, "ctOfMarkEdge",
                        Fmt.Int(alg.eventDataRec.ctOfMarkEdge));
    FormsVBT.PutText(fv, "ctOfUnMarkEdge",
                        Fmt.Int(alg.eventDataRec.ctOfUnMarkEdge));
    FormsVBT.PutText(fv, "ctOfMarkVertex",
                        Fmt.Int(alg.eventDataRec.ctOfMarkVertex));
    FormsVBT.PutText(fv, "ctOfUnMarkVertex",
                        Fmt.Int(alg.eventDataRec.ctOfUnMarkVertex));
    FormsVBT.PutText(fv, "ctOfNewTree",
                        Fmt.Int(alg.eventDataRec.ctOfNewTree));
    FormsVBT.PutText(fv, "ctOfHighlight",
                        Fmt.Int(alg.eventDataRec.ctOfHighlight));
    FormsVBT.PutText(fv, "ctOfAddChild",
                        Fmt.Int(alg.eventDataRec.ctOfAddChild));
    FormsVBT.PutText(fv, "ctOfRemoveChild",
                        Fmt.Int(alg.eventDataRec.ctOfRemoveChild));
  END CountsToFV;

PROCEDURE DGraphDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfSetup := 0;
      v.eventDataRec.ctOfAddEdge := 0;
      v.eventDataRec.ctOfMarkEdge := 0;
      v.eventDataRec.ctOfUnMarkEdge := 0;
      v.eventDataRec.ctOfMarkVertex := 0;
      v.eventDataRec.ctOfUnMarkVertex := 0;
      v.eventDataRec.ctOfNewTree := 0;
      v.eventDataRec.ctOfHighlight := 0;
      v.eventDataRec.ctOfAddChild := 0;
      v.eventDataRec.ctOfRemoveChild := 0;
    END;
    CountsToFV (v.eventData, v);
  END DGraphDefaultUpdateCts;

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

PROCEDURE DGraphDefaultRestore (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(
          "DGraphAlgClass.DGraphDefaultRestore read error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "DGraphAlgClass.DGraphDefaultRestore: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.restore(rd);
      v.updateEventCounts(FALSE);
      FromFV(v.eventData, v);
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "DGraphAlgClass.DGraphDefaultRestore error");
    END;
    Algorithm.T.restore(v, rd);
    IF NOT ZeusUtil.EatChar(rd, ')') THEN
      RAISE ZeusClass.Error(
          "DGraphAlgClass.DGraphDefaultRestore read error");
    END;
  END DGraphDefaultRestore;

BEGIN
END DGraphAlgClass.