mentor/derived/ShortestPathAlgClass.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 ShortestPath.evt.
      ********************************************************************


MODULE ShortestPathAlgClass;

<*NOWARN*> IMPORT TextConv, 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 := ShortestPathDefaultInit;
        snapshot := ShortestPathDefaultSnapshot;
        restore := ShortestPathDefaultRestore;
        updateEventCounts := ShortestPathDefaultUpdateCts;
      END;

PROCEDURE ShortestPathDefaultInit (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("ShortestPathEventData.fv");
    Attach("stopatCodeEvents", ShortestPathDoIt);
    Attach("waitatCodeEvents", ShortestPathDoIt);
    Attach("eventCounts", ShortestPathRefreshCts);
    Attach("stopAtNewVertex", ShortestPathDoIt);
    Attach("waitAtNewVertex", ShortestPathDoIt);
    Attach("stopAtNewEdge", ShortestPathDoIt);
    Attach("waitAtNewEdge", ShortestPathDoIt);
    Attach("stopAtStartFind", ShortestPathDoIt);
    Attach("waitAtStartFind", ShortestPathDoIt);
    Attach("stopAtPromote", ShortestPathDoIt);
    Attach("waitAtPromote", ShortestPathDoIt);
    Attach("stopAtConsider", ShortestPathDoIt);
    Attach("waitAtConsider", ShortestPathDoIt);
    Attach("stopAtTraceback", ShortestPathDoIt);
    Attach("waitAtTraceback", ShortestPathDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END ShortestPathDefaultInit;

PROCEDURE ShortestPathDoIt (           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, "stopAtNewVertex") THEN
      NARROW(arg, T).eventDataRec.stopAtNewVertex :=
          FormsVBT.GetBoolean(fv, "stopAtNewVertex");
    END;
    IF Text.Equal(e, "waitAtNewVertex") THEN
      NARROW(arg, T).eventDataRec.waitAtNewVertex :=
          FormsVBT.GetInteger(fv, "waitAtNewVertex");
    END;
    IF Text.Equal(e, "stopAtNewEdge") THEN
      NARROW(arg, T).eventDataRec.stopAtNewEdge :=
          FormsVBT.GetBoolean(fv, "stopAtNewEdge");
    END;
    IF Text.Equal(e, "waitAtNewEdge") THEN
      NARROW(arg, T).eventDataRec.waitAtNewEdge :=
          FormsVBT.GetInteger(fv, "waitAtNewEdge");
    END;
    IF Text.Equal(e, "stopAtStartFind") THEN
      NARROW(arg, T).eventDataRec.stopAtStartFind :=
          FormsVBT.GetBoolean(fv, "stopAtStartFind");
    END;
    IF Text.Equal(e, "waitAtStartFind") THEN
      NARROW(arg, T).eventDataRec.waitAtStartFind :=
          FormsVBT.GetInteger(fv, "waitAtStartFind");
    END;
    IF Text.Equal(e, "stopAtPromote") THEN
      NARROW(arg, T).eventDataRec.stopAtPromote :=
          FormsVBT.GetBoolean(fv, "stopAtPromote");
    END;
    IF Text.Equal(e, "waitAtPromote") THEN
      NARROW(arg, T).eventDataRec.waitAtPromote :=
          FormsVBT.GetInteger(fv, "waitAtPromote");
    END;
    IF Text.Equal(e, "stopAtConsider") THEN
      NARROW(arg, T).eventDataRec.stopAtConsider :=
          FormsVBT.GetBoolean(fv, "stopAtConsider");
    END;
    IF Text.Equal(e, "waitAtConsider") THEN
      NARROW(arg, T).eventDataRec.waitAtConsider :=
          FormsVBT.GetInteger(fv, "waitAtConsider");
    END;
    IF Text.Equal(e, "stopAtTraceback") THEN
      NARROW(arg, T).eventDataRec.stopAtTraceback :=
          FormsVBT.GetBoolean(fv, "stopAtTraceback");
    END;
    IF Text.Equal(e, "waitAtTraceback") THEN
      NARROW(arg, T).eventDataRec.waitAtTraceback :=
          FormsVBT.GetInteger(fv, "waitAtTraceback");
    END;
  END ShortestPathDoIt;

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

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.stopAtNewVertex :=
        FormsVBT.GetBoolean(fv, "stopAtNewVertex");
    alg.eventDataRec.waitAtNewVertex :=
        FormsVBT.GetInteger(fv, "waitAtNewVertex");
    alg.eventDataRec.stopAtNewEdge :=
        FormsVBT.GetBoolean(fv, "stopAtNewEdge");
    alg.eventDataRec.waitAtNewEdge :=
        FormsVBT.GetInteger(fv, "waitAtNewEdge");
    alg.eventDataRec.stopAtStartFind :=
        FormsVBT.GetBoolean(fv, "stopAtStartFind");
    alg.eventDataRec.waitAtStartFind :=
        FormsVBT.GetInteger(fv, "waitAtStartFind");
    alg.eventDataRec.stopAtPromote :=
        FormsVBT.GetBoolean(fv, "stopAtPromote");
    alg.eventDataRec.waitAtPromote :=
        FormsVBT.GetInteger(fv, "waitAtPromote");
    alg.eventDataRec.stopAtConsider :=
        FormsVBT.GetBoolean(fv, "stopAtConsider");
    alg.eventDataRec.waitAtConsider :=
        FormsVBT.GetInteger(fv, "waitAtConsider");
    alg.eventDataRec.stopAtTraceback :=
        FormsVBT.GetBoolean(fv, "stopAtTraceback");
    alg.eventDataRec.waitAtTraceback :=
        FormsVBT.GetInteger(fv, "waitAtTraceback");
  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, "stopAtNewVertex",
                        alg.eventDataRec.stopAtNewVertex);
    FormsVBT.PutInteger(fv, "waitAtNewVertex",
                        alg.eventDataRec.waitAtNewVertex);
    FormsVBT.PutBoolean(fv, "stopAtNewEdge",
                        alg.eventDataRec.stopAtNewEdge);
    FormsVBT.PutInteger(fv, "waitAtNewEdge",
                        alg.eventDataRec.waitAtNewEdge);
    FormsVBT.PutBoolean(fv, "stopAtStartFind",
                        alg.eventDataRec.stopAtStartFind);
    FormsVBT.PutInteger(fv, "waitAtStartFind",
                        alg.eventDataRec.waitAtStartFind);
    FormsVBT.PutBoolean(fv, "stopAtPromote",
                        alg.eventDataRec.stopAtPromote);
    FormsVBT.PutInteger(fv, "waitAtPromote",
                        alg.eventDataRec.waitAtPromote);
    FormsVBT.PutBoolean(fv, "stopAtConsider",
                        alg.eventDataRec.stopAtConsider);
    FormsVBT.PutInteger(fv, "waitAtConsider",
                        alg.eventDataRec.waitAtConsider);
    FormsVBT.PutBoolean(fv, "stopAtTraceback",
                        alg.eventDataRec.stopAtTraceback);
    FormsVBT.PutInteger(fv, "waitAtTraceback",
                        alg.eventDataRec.waitAtTraceback);
    CountsToFV (fv, alg);
  END ToFV;

PROCEDURE CountsToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutText(fv, "ctOfNewVertex",
                        Fmt.Int(alg.eventDataRec.ctOfNewVertex));
    FormsVBT.PutText(fv, "ctOfNewEdge",
                        Fmt.Int(alg.eventDataRec.ctOfNewEdge));
    FormsVBT.PutText(fv, "ctOfStartFind",
                        Fmt.Int(alg.eventDataRec.ctOfStartFind));
    FormsVBT.PutText(fv, "ctOfPromote",
                        Fmt.Int(alg.eventDataRec.ctOfPromote));
    FormsVBT.PutText(fv, "ctOfConsider",
                        Fmt.Int(alg.eventDataRec.ctOfConsider));
    FormsVBT.PutText(fv, "ctOfTraceback",
                        Fmt.Int(alg.eventDataRec.ctOfTraceback));
  END CountsToFV;

PROCEDURE ShortestPathDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfNewVertex := 0;
      v.eventDataRec.ctOfNewEdge := 0;
      v.eventDataRec.ctOfStartFind := 0;
      v.eventDataRec.ctOfPromote := 0;
      v.eventDataRec.ctOfConsider := 0;
      v.eventDataRec.ctOfTraceback := 0;
    END;
    CountsToFV (v.eventData, v);
  END ShortestPathDefaultUpdateCts;

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

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

BEGIN
END ShortestPathAlgClass.