mentor/derived/SearchTreeAlgClass.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 SearchTree.evt.
      ********************************************************************


MODULE SearchTreeAlgClass;

<*NOWARN*> IMPORT Rd, ZeusClass, Fmt, Algorithm, RedBlackAlg, 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 := SearchTreeDefaultInit;
        snapshot := SearchTreeDefaultSnapshot;
        restore := SearchTreeDefaultRestore;
        updateEventCounts := SearchTreeDefaultUpdateCts;
      END;

PROCEDURE SearchTreeDefaultInit (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("SearchTreeEventData.fv");
    Attach("stopatCodeEvents", SearchTreeDoIt);
    Attach("waitatCodeEvents", SearchTreeDoIt);
    Attach("eventCounts", SearchTreeRefreshCts);
    Attach("stopAtNewNode", SearchTreeDoIt);
    Attach("waitAtNewNode", SearchTreeDoIt);
    Attach("stopAtCompareKeys", SearchTreeDoIt);
    Attach("waitAtCompareKeys", SearchTreeDoIt);
    Attach("stopAtAddLeaf", SearchTreeDoIt);
    Attach("waitAtAddLeaf", SearchTreeDoIt);
    Attach("stopAtNewSearchKey", SearchTreeDoIt);
    Attach("waitAtNewSearchKey", SearchTreeDoIt);
    Attach("stopAtSearchEnd", SearchTreeDoIt);
    Attach("waitAtSearchEnd", SearchTreeDoIt);
    Attach("stopAtGoLeft", SearchTreeDoIt);
    Attach("waitAtGoLeft", SearchTreeDoIt);
    Attach("stopAtSpliceOut", SearchTreeDoIt);
    Attach("waitAtSpliceOut", SearchTreeDoIt);
    Attach("stopAtCopy", SearchTreeDoIt);
    Attach("waitAtCopy", SearchTreeDoIt);
    Attach("stopAtCurrentNode", SearchTreeDoIt);
    Attach("waitAtCurrentNode", SearchTreeDoIt);
    Attach("stopAtSetType", SearchTreeDoIt);
    Attach("waitAtSetType", SearchTreeDoIt);
    Attach("stopAtRedRedClash", SearchTreeDoIt);
    Attach("waitAtRedRedClash", SearchTreeDoIt);
    Attach("stopAtCheckUncle", SearchTreeDoIt);
    Attach("waitAtCheckUncle", SearchTreeDoIt);
    Attach("stopAtRotate", SearchTreeDoIt);
    Attach("waitAtRotate", SearchTreeDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END SearchTreeDefaultInit;

PROCEDURE SearchTreeDoIt (           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, "stopAtNewNode") THEN
      NARROW(arg, T).eventDataRec.stopAtNewNode :=
          FormsVBT.GetBoolean(fv, "stopAtNewNode");
    END;
    IF Text.Equal(e, "waitAtNewNode") THEN
      NARROW(arg, T).eventDataRec.waitAtNewNode :=
          FormsVBT.GetInteger(fv, "waitAtNewNode");
    END;
    IF Text.Equal(e, "stopAtCompareKeys") THEN
      NARROW(arg, T).eventDataRec.stopAtCompareKeys :=
          FormsVBT.GetBoolean(fv, "stopAtCompareKeys");
    END;
    IF Text.Equal(e, "waitAtCompareKeys") THEN
      NARROW(arg, T).eventDataRec.waitAtCompareKeys :=
          FormsVBT.GetInteger(fv, "waitAtCompareKeys");
    END;
    IF Text.Equal(e, "stopAtAddLeaf") THEN
      NARROW(arg, T).eventDataRec.stopAtAddLeaf :=
          FormsVBT.GetBoolean(fv, "stopAtAddLeaf");
    END;
    IF Text.Equal(e, "waitAtAddLeaf") THEN
      NARROW(arg, T).eventDataRec.waitAtAddLeaf :=
          FormsVBT.GetInteger(fv, "waitAtAddLeaf");
    END;
    IF Text.Equal(e, "stopAtNewSearchKey") THEN
      NARROW(arg, T).eventDataRec.stopAtNewSearchKey :=
          FormsVBT.GetBoolean(fv, "stopAtNewSearchKey");
    END;
    IF Text.Equal(e, "waitAtNewSearchKey") THEN
      NARROW(arg, T).eventDataRec.waitAtNewSearchKey :=
          FormsVBT.GetInteger(fv, "waitAtNewSearchKey");
    END;
    IF Text.Equal(e, "stopAtSearchEnd") THEN
      NARROW(arg, T).eventDataRec.stopAtSearchEnd :=
          FormsVBT.GetBoolean(fv, "stopAtSearchEnd");
    END;
    IF Text.Equal(e, "waitAtSearchEnd") THEN
      NARROW(arg, T).eventDataRec.waitAtSearchEnd :=
          FormsVBT.GetInteger(fv, "waitAtSearchEnd");
    END;
    IF Text.Equal(e, "stopAtGoLeft") THEN
      NARROW(arg, T).eventDataRec.stopAtGoLeft :=
          FormsVBT.GetBoolean(fv, "stopAtGoLeft");
    END;
    IF Text.Equal(e, "waitAtGoLeft") THEN
      NARROW(arg, T).eventDataRec.waitAtGoLeft :=
          FormsVBT.GetInteger(fv, "waitAtGoLeft");
    END;
    IF Text.Equal(e, "stopAtSpliceOut") THEN
      NARROW(arg, T).eventDataRec.stopAtSpliceOut :=
          FormsVBT.GetBoolean(fv, "stopAtSpliceOut");
    END;
    IF Text.Equal(e, "waitAtSpliceOut") THEN
      NARROW(arg, T).eventDataRec.waitAtSpliceOut :=
          FormsVBT.GetInteger(fv, "waitAtSpliceOut");
    END;
    IF Text.Equal(e, "stopAtCopy") THEN
      NARROW(arg, T).eventDataRec.stopAtCopy :=
          FormsVBT.GetBoolean(fv, "stopAtCopy");
    END;
    IF Text.Equal(e, "waitAtCopy") THEN
      NARROW(arg, T).eventDataRec.waitAtCopy :=
          FormsVBT.GetInteger(fv, "waitAtCopy");
    END;
    IF Text.Equal(e, "stopAtCurrentNode") THEN
      NARROW(arg, T).eventDataRec.stopAtCurrentNode :=
          FormsVBT.GetBoolean(fv, "stopAtCurrentNode");
    END;
    IF Text.Equal(e, "waitAtCurrentNode") THEN
      NARROW(arg, T).eventDataRec.waitAtCurrentNode :=
          FormsVBT.GetInteger(fv, "waitAtCurrentNode");
    END;
    IF Text.Equal(e, "stopAtSetType") THEN
      NARROW(arg, T).eventDataRec.stopAtSetType :=
          FormsVBT.GetBoolean(fv, "stopAtSetType");
    END;
    IF Text.Equal(e, "waitAtSetType") THEN
      NARROW(arg, T).eventDataRec.waitAtSetType :=
          FormsVBT.GetInteger(fv, "waitAtSetType");
    END;
    IF Text.Equal(e, "stopAtRedRedClash") THEN
      NARROW(arg, T).eventDataRec.stopAtRedRedClash :=
          FormsVBT.GetBoolean(fv, "stopAtRedRedClash");
    END;
    IF Text.Equal(e, "waitAtRedRedClash") THEN
      NARROW(arg, T).eventDataRec.waitAtRedRedClash :=
          FormsVBT.GetInteger(fv, "waitAtRedRedClash");
    END;
    IF Text.Equal(e, "stopAtCheckUncle") THEN
      NARROW(arg, T).eventDataRec.stopAtCheckUncle :=
          FormsVBT.GetBoolean(fv, "stopAtCheckUncle");
    END;
    IF Text.Equal(e, "waitAtCheckUncle") THEN
      NARROW(arg, T).eventDataRec.waitAtCheckUncle :=
          FormsVBT.GetInteger(fv, "waitAtCheckUncle");
    END;
    IF Text.Equal(e, "stopAtRotate") THEN
      NARROW(arg, T).eventDataRec.stopAtRotate :=
          FormsVBT.GetBoolean(fv, "stopAtRotate");
    END;
    IF Text.Equal(e, "waitAtRotate") THEN
      NARROW(arg, T).eventDataRec.waitAtRotate :=
          FormsVBT.GetInteger(fv, "waitAtRotate");
    END;
  END SearchTreeDoIt;

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

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.stopAtNewNode :=
        FormsVBT.GetBoolean(fv, "stopAtNewNode");
    alg.eventDataRec.waitAtNewNode :=
        FormsVBT.GetInteger(fv, "waitAtNewNode");
    alg.eventDataRec.stopAtCompareKeys :=
        FormsVBT.GetBoolean(fv, "stopAtCompareKeys");
    alg.eventDataRec.waitAtCompareKeys :=
        FormsVBT.GetInteger(fv, "waitAtCompareKeys");
    alg.eventDataRec.stopAtAddLeaf :=
        FormsVBT.GetBoolean(fv, "stopAtAddLeaf");
    alg.eventDataRec.waitAtAddLeaf :=
        FormsVBT.GetInteger(fv, "waitAtAddLeaf");
    alg.eventDataRec.stopAtNewSearchKey :=
        FormsVBT.GetBoolean(fv, "stopAtNewSearchKey");
    alg.eventDataRec.waitAtNewSearchKey :=
        FormsVBT.GetInteger(fv, "waitAtNewSearchKey");
    alg.eventDataRec.stopAtSearchEnd :=
        FormsVBT.GetBoolean(fv, "stopAtSearchEnd");
    alg.eventDataRec.waitAtSearchEnd :=
        FormsVBT.GetInteger(fv, "waitAtSearchEnd");
    alg.eventDataRec.stopAtGoLeft :=
        FormsVBT.GetBoolean(fv, "stopAtGoLeft");
    alg.eventDataRec.waitAtGoLeft :=
        FormsVBT.GetInteger(fv, "waitAtGoLeft");
    alg.eventDataRec.stopAtSpliceOut :=
        FormsVBT.GetBoolean(fv, "stopAtSpliceOut");
    alg.eventDataRec.waitAtSpliceOut :=
        FormsVBT.GetInteger(fv, "waitAtSpliceOut");
    alg.eventDataRec.stopAtCopy :=
        FormsVBT.GetBoolean(fv, "stopAtCopy");
    alg.eventDataRec.waitAtCopy :=
        FormsVBT.GetInteger(fv, "waitAtCopy");
    alg.eventDataRec.stopAtCurrentNode :=
        FormsVBT.GetBoolean(fv, "stopAtCurrentNode");
    alg.eventDataRec.waitAtCurrentNode :=
        FormsVBT.GetInteger(fv, "waitAtCurrentNode");
    alg.eventDataRec.stopAtSetType :=
        FormsVBT.GetBoolean(fv, "stopAtSetType");
    alg.eventDataRec.waitAtSetType :=
        FormsVBT.GetInteger(fv, "waitAtSetType");
    alg.eventDataRec.stopAtRedRedClash :=
        FormsVBT.GetBoolean(fv, "stopAtRedRedClash");
    alg.eventDataRec.waitAtRedRedClash :=
        FormsVBT.GetInteger(fv, "waitAtRedRedClash");
    alg.eventDataRec.stopAtCheckUncle :=
        FormsVBT.GetBoolean(fv, "stopAtCheckUncle");
    alg.eventDataRec.waitAtCheckUncle :=
        FormsVBT.GetInteger(fv, "waitAtCheckUncle");
    alg.eventDataRec.stopAtRotate :=
        FormsVBT.GetBoolean(fv, "stopAtRotate");
    alg.eventDataRec.waitAtRotate :=
        FormsVBT.GetInteger(fv, "waitAtRotate");
  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, "stopAtNewNode",
                        alg.eventDataRec.stopAtNewNode);
    FormsVBT.PutInteger(fv, "waitAtNewNode",
                        alg.eventDataRec.waitAtNewNode);
    FormsVBT.PutBoolean(fv, "stopAtCompareKeys",
                        alg.eventDataRec.stopAtCompareKeys);
    FormsVBT.PutInteger(fv, "waitAtCompareKeys",
                        alg.eventDataRec.waitAtCompareKeys);
    FormsVBT.PutBoolean(fv, "stopAtAddLeaf",
                        alg.eventDataRec.stopAtAddLeaf);
    FormsVBT.PutInteger(fv, "waitAtAddLeaf",
                        alg.eventDataRec.waitAtAddLeaf);
    FormsVBT.PutBoolean(fv, "stopAtNewSearchKey",
                        alg.eventDataRec.stopAtNewSearchKey);
    FormsVBT.PutInteger(fv, "waitAtNewSearchKey",
                        alg.eventDataRec.waitAtNewSearchKey);
    FormsVBT.PutBoolean(fv, "stopAtSearchEnd",
                        alg.eventDataRec.stopAtSearchEnd);
    FormsVBT.PutInteger(fv, "waitAtSearchEnd",
                        alg.eventDataRec.waitAtSearchEnd);
    FormsVBT.PutBoolean(fv, "stopAtGoLeft",
                        alg.eventDataRec.stopAtGoLeft);
    FormsVBT.PutInteger(fv, "waitAtGoLeft",
                        alg.eventDataRec.waitAtGoLeft);
    FormsVBT.PutBoolean(fv, "stopAtSpliceOut",
                        alg.eventDataRec.stopAtSpliceOut);
    FormsVBT.PutInteger(fv, "waitAtSpliceOut",
                        alg.eventDataRec.waitAtSpliceOut);
    FormsVBT.PutBoolean(fv, "stopAtCopy",
                        alg.eventDataRec.stopAtCopy);
    FormsVBT.PutInteger(fv, "waitAtCopy",
                        alg.eventDataRec.waitAtCopy);
    FormsVBT.PutBoolean(fv, "stopAtCurrentNode",
                        alg.eventDataRec.stopAtCurrentNode);
    FormsVBT.PutInteger(fv, "waitAtCurrentNode",
                        alg.eventDataRec.waitAtCurrentNode);
    FormsVBT.PutBoolean(fv, "stopAtSetType",
                        alg.eventDataRec.stopAtSetType);
    FormsVBT.PutInteger(fv, "waitAtSetType",
                        alg.eventDataRec.waitAtSetType);
    FormsVBT.PutBoolean(fv, "stopAtRedRedClash",
                        alg.eventDataRec.stopAtRedRedClash);
    FormsVBT.PutInteger(fv, "waitAtRedRedClash",
                        alg.eventDataRec.waitAtRedRedClash);
    FormsVBT.PutBoolean(fv, "stopAtCheckUncle",
                        alg.eventDataRec.stopAtCheckUncle);
    FormsVBT.PutInteger(fv, "waitAtCheckUncle",
                        alg.eventDataRec.waitAtCheckUncle);
    FormsVBT.PutBoolean(fv, "stopAtRotate",
                        alg.eventDataRec.stopAtRotate);
    FormsVBT.PutInteger(fv, "waitAtRotate",
                        alg.eventDataRec.waitAtRotate);
    CountsToFV (fv, alg);
  END ToFV;

PROCEDURE CountsToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutText(fv, "ctOfNewNode",
                        Fmt.Int(alg.eventDataRec.ctOfNewNode));
    FormsVBT.PutText(fv, "ctOfCompareKeys",
                        Fmt.Int(alg.eventDataRec.ctOfCompareKeys));
    FormsVBT.PutText(fv, "ctOfAddLeaf",
                        Fmt.Int(alg.eventDataRec.ctOfAddLeaf));
    FormsVBT.PutText(fv, "ctOfNewSearchKey",
                        Fmt.Int(alg.eventDataRec.ctOfNewSearchKey));
    FormsVBT.PutText(fv, "ctOfSearchEnd",
                        Fmt.Int(alg.eventDataRec.ctOfSearchEnd));
    FormsVBT.PutText(fv, "ctOfGoLeft",
                        Fmt.Int(alg.eventDataRec.ctOfGoLeft));
    FormsVBT.PutText(fv, "ctOfSpliceOut",
                        Fmt.Int(alg.eventDataRec.ctOfSpliceOut));
    FormsVBT.PutText(fv, "ctOfCopy",
                        Fmt.Int(alg.eventDataRec.ctOfCopy));
    FormsVBT.PutText(fv, "ctOfCurrentNode",
                        Fmt.Int(alg.eventDataRec.ctOfCurrentNode));
    FormsVBT.PutText(fv, "ctOfSetType",
                        Fmt.Int(alg.eventDataRec.ctOfSetType));
    FormsVBT.PutText(fv, "ctOfRedRedClash",
                        Fmt.Int(alg.eventDataRec.ctOfRedRedClash));
    FormsVBT.PutText(fv, "ctOfCheckUncle",
                        Fmt.Int(alg.eventDataRec.ctOfCheckUncle));
    FormsVBT.PutText(fv, "ctOfRotate",
                        Fmt.Int(alg.eventDataRec.ctOfRotate));
  END CountsToFV;

PROCEDURE SearchTreeDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfNewNode := 0;
      v.eventDataRec.ctOfCompareKeys := 0;
      v.eventDataRec.ctOfAddLeaf := 0;
      v.eventDataRec.ctOfNewSearchKey := 0;
      v.eventDataRec.ctOfSearchEnd := 0;
      v.eventDataRec.ctOfGoLeft := 0;
      v.eventDataRec.ctOfSpliceOut := 0;
      v.eventDataRec.ctOfCopy := 0;
      v.eventDataRec.ctOfCurrentNode := 0;
      v.eventDataRec.ctOfSetType := 0;
      v.eventDataRec.ctOfRedRedClash := 0;
      v.eventDataRec.ctOfCheckUncle := 0;
      v.eventDataRec.ctOfRotate := 0;
    END;
    CountsToFV (v.eventData, v);
  END SearchTreeDefaultUpdateCts;

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

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

BEGIN
END SearchTreeAlgClass.