mentor/derived/StringSearchAlgClass.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 StringSearch.evt.
      ********************************************************************


MODULE StringSearchAlgClass;

<*NOWARN*> IMPORT Rd, ZeusClass, Fmt, Algorithm, Wr, ZeusPanel;
<*NOWARN*> IMPORT 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 := StringSearchDefaultInit;
        snapshot := StringSearchDefaultSnapshot;
        restore := StringSearchDefaultRestore;
        updateEventCounts := StringSearchDefaultUpdateCts;
      END;

PROCEDURE StringSearchDefaultInit (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("StringSearchEventData.fv");
    Attach("stopatCodeEvents", StringSearchDoIt);
    Attach("waitatCodeEvents", StringSearchDoIt);
    Attach("eventCounts", StringSearchRefreshCts);
    Attach("stopAtSetup", StringSearchDoIt);
    Attach("waitAtSetup", StringSearchDoIt);
    Attach("stopAtProbe", StringSearchDoIt);
    Attach("waitAtProbe", StringSearchDoIt);
    Attach("stopAtResult", StringSearchDoIt);
    Attach("waitAtResult", StringSearchDoIt);
    Attach("stopAtPartialMatch", StringSearchDoIt);
    Attach("waitAtPartialMatch", StringSearchDoIt);
    Attach("stopAtPartialMatchClear", StringSearchDoIt);
    Attach("waitAtPartialMatchClear", StringSearchDoIt);
    Attach("stopAtCompleteMatch", StringSearchDoIt);
    Attach("waitAtCompleteMatch", StringSearchDoIt);
    Attach("stopAtSlideTo", StringSearchDoIt);
    Attach("waitAtSlideTo", StringSearchDoIt);
    Attach("stopAtKMPSetup", StringSearchDoIt);
    Attach("waitAtKMPSetup", StringSearchDoIt);
    Attach("stopAtAddEdge", StringSearchDoIt);
    Attach("waitAtAddEdge", StringSearchDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END StringSearchDefaultInit;

PROCEDURE StringSearchDoIt (           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, "stopAtProbe") THEN
      NARROW(arg, T).eventDataRec.stopAtProbe :=
          FormsVBT.GetBoolean(fv, "stopAtProbe");
    END;
    IF Text.Equal(e, "waitAtProbe") THEN
      NARROW(arg, T).eventDataRec.waitAtProbe :=
          FormsVBT.GetInteger(fv, "waitAtProbe");
    END;
    IF Text.Equal(e, "stopAtResult") THEN
      NARROW(arg, T).eventDataRec.stopAtResult :=
          FormsVBT.GetBoolean(fv, "stopAtResult");
    END;
    IF Text.Equal(e, "waitAtResult") THEN
      NARROW(arg, T).eventDataRec.waitAtResult :=
          FormsVBT.GetInteger(fv, "waitAtResult");
    END;
    IF Text.Equal(e, "stopAtPartialMatch") THEN
      NARROW(arg, T).eventDataRec.stopAtPartialMatch :=
          FormsVBT.GetBoolean(fv, "stopAtPartialMatch");
    END;
    IF Text.Equal(e, "waitAtPartialMatch") THEN
      NARROW(arg, T).eventDataRec.waitAtPartialMatch :=
          FormsVBT.GetInteger(fv, "waitAtPartialMatch");
    END;
    IF Text.Equal(e, "stopAtPartialMatchClear") THEN
      NARROW(arg, T).eventDataRec.stopAtPartialMatchClear :=
          FormsVBT.GetBoolean(fv, "stopAtPartialMatchClear");
    END;
    IF Text.Equal(e, "waitAtPartialMatchClear") THEN
      NARROW(arg, T).eventDataRec.waitAtPartialMatchClear :=
          FormsVBT.GetInteger(fv, "waitAtPartialMatchClear");
    END;
    IF Text.Equal(e, "stopAtCompleteMatch") THEN
      NARROW(arg, T).eventDataRec.stopAtCompleteMatch :=
          FormsVBT.GetBoolean(fv, "stopAtCompleteMatch");
    END;
    IF Text.Equal(e, "waitAtCompleteMatch") THEN
      NARROW(arg, T).eventDataRec.waitAtCompleteMatch :=
          FormsVBT.GetInteger(fv, "waitAtCompleteMatch");
    END;
    IF Text.Equal(e, "stopAtSlideTo") THEN
      NARROW(arg, T).eventDataRec.stopAtSlideTo :=
          FormsVBT.GetBoolean(fv, "stopAtSlideTo");
    END;
    IF Text.Equal(e, "waitAtSlideTo") THEN
      NARROW(arg, T).eventDataRec.waitAtSlideTo :=
          FormsVBT.GetInteger(fv, "waitAtSlideTo");
    END;
    IF Text.Equal(e, "stopAtKMPSetup") THEN
      NARROW(arg, T).eventDataRec.stopAtKMPSetup :=
          FormsVBT.GetBoolean(fv, "stopAtKMPSetup");
    END;
    IF Text.Equal(e, "waitAtKMPSetup") THEN
      NARROW(arg, T).eventDataRec.waitAtKMPSetup :=
          FormsVBT.GetInteger(fv, "waitAtKMPSetup");
    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;
  END StringSearchDoIt;

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

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.stopAtProbe :=
        FormsVBT.GetBoolean(fv, "stopAtProbe");
    alg.eventDataRec.waitAtProbe :=
        FormsVBT.GetInteger(fv, "waitAtProbe");
    alg.eventDataRec.stopAtResult :=
        FormsVBT.GetBoolean(fv, "stopAtResult");
    alg.eventDataRec.waitAtResult :=
        FormsVBT.GetInteger(fv, "waitAtResult");
    alg.eventDataRec.stopAtPartialMatch :=
        FormsVBT.GetBoolean(fv, "stopAtPartialMatch");
    alg.eventDataRec.waitAtPartialMatch :=
        FormsVBT.GetInteger(fv, "waitAtPartialMatch");
    alg.eventDataRec.stopAtPartialMatchClear :=
        FormsVBT.GetBoolean(fv, "stopAtPartialMatchClear");
    alg.eventDataRec.waitAtPartialMatchClear :=
        FormsVBT.GetInteger(fv, "waitAtPartialMatchClear");
    alg.eventDataRec.stopAtCompleteMatch :=
        FormsVBT.GetBoolean(fv, "stopAtCompleteMatch");
    alg.eventDataRec.waitAtCompleteMatch :=
        FormsVBT.GetInteger(fv, "waitAtCompleteMatch");
    alg.eventDataRec.stopAtSlideTo :=
        FormsVBT.GetBoolean(fv, "stopAtSlideTo");
    alg.eventDataRec.waitAtSlideTo :=
        FormsVBT.GetInteger(fv, "waitAtSlideTo");
    alg.eventDataRec.stopAtKMPSetup :=
        FormsVBT.GetBoolean(fv, "stopAtKMPSetup");
    alg.eventDataRec.waitAtKMPSetup :=
        FormsVBT.GetInteger(fv, "waitAtKMPSetup");
    alg.eventDataRec.stopAtAddEdge :=
        FormsVBT.GetBoolean(fv, "stopAtAddEdge");
    alg.eventDataRec.waitAtAddEdge :=
        FormsVBT.GetInteger(fv, "waitAtAddEdge");
  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, "stopAtProbe",
                        alg.eventDataRec.stopAtProbe);
    FormsVBT.PutInteger(fv, "waitAtProbe",
                        alg.eventDataRec.waitAtProbe);
    FormsVBT.PutBoolean(fv, "stopAtResult",
                        alg.eventDataRec.stopAtResult);
    FormsVBT.PutInteger(fv, "waitAtResult",
                        alg.eventDataRec.waitAtResult);
    FormsVBT.PutBoolean(fv, "stopAtPartialMatch",
                        alg.eventDataRec.stopAtPartialMatch);
    FormsVBT.PutInteger(fv, "waitAtPartialMatch",
                        alg.eventDataRec.waitAtPartialMatch);
    FormsVBT.PutBoolean(fv, "stopAtPartialMatchClear",
                        alg.eventDataRec.stopAtPartialMatchClear);
    FormsVBT.PutInteger(fv, "waitAtPartialMatchClear",
                        alg.eventDataRec.waitAtPartialMatchClear);
    FormsVBT.PutBoolean(fv, "stopAtCompleteMatch",
                        alg.eventDataRec.stopAtCompleteMatch);
    FormsVBT.PutInteger(fv, "waitAtCompleteMatch",
                        alg.eventDataRec.waitAtCompleteMatch);
    FormsVBT.PutBoolean(fv, "stopAtSlideTo",
                        alg.eventDataRec.stopAtSlideTo);
    FormsVBT.PutInteger(fv, "waitAtSlideTo",
                        alg.eventDataRec.waitAtSlideTo);
    FormsVBT.PutBoolean(fv, "stopAtKMPSetup",
                        alg.eventDataRec.stopAtKMPSetup);
    FormsVBT.PutInteger(fv, "waitAtKMPSetup",
                        alg.eventDataRec.waitAtKMPSetup);
    FormsVBT.PutBoolean(fv, "stopAtAddEdge",
                        alg.eventDataRec.stopAtAddEdge);
    FormsVBT.PutInteger(fv, "waitAtAddEdge",
                        alg.eventDataRec.waitAtAddEdge);
    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, "ctOfProbe",
                        Fmt.Int(alg.eventDataRec.ctOfProbe));
    FormsVBT.PutText(fv, "ctOfResult",
                        Fmt.Int(alg.eventDataRec.ctOfResult));
    FormsVBT.PutText(fv, "ctOfPartialMatch",
                        Fmt.Int(alg.eventDataRec.ctOfPartialMatch));
    FormsVBT.PutText(fv, "ctOfPartialMatchClear",
                        Fmt.Int(alg.eventDataRec.ctOfPartialMatchClear));
    FormsVBT.PutText(fv, "ctOfCompleteMatch",
                        Fmt.Int(alg.eventDataRec.ctOfCompleteMatch));
    FormsVBT.PutText(fv, "ctOfSlideTo",
                        Fmt.Int(alg.eventDataRec.ctOfSlideTo));
    FormsVBT.PutText(fv, "ctOfKMPSetup",
                        Fmt.Int(alg.eventDataRec.ctOfKMPSetup));
    FormsVBT.PutText(fv, "ctOfAddEdge",
                        Fmt.Int(alg.eventDataRec.ctOfAddEdge));
  END CountsToFV;

PROCEDURE StringSearchDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfSetup := 0;
      v.eventDataRec.ctOfProbe := 0;
      v.eventDataRec.ctOfResult := 0;
      v.eventDataRec.ctOfPartialMatch := 0;
      v.eventDataRec.ctOfPartialMatchClear := 0;
      v.eventDataRec.ctOfCompleteMatch := 0;
      v.eventDataRec.ctOfSlideTo := 0;
      v.eventDataRec.ctOfKMPSetup := 0;
      v.eventDataRec.ctOfAddEdge := 0;
    END;
    CountsToFV (v.eventData, v);
  END StringSearchDefaultUpdateCts;

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

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

BEGIN
END StringSearchAlgClass.