mentor/derived/UnionFindTranscriptView.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:56:02 PST 1995 by kalsow  
      modified on Mon Jun  6 03:18:55 PDT 1994 by mhb   
      modified on Tue Feb 16 16:31:40 PST 1993 by johnh 

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

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


<* PRAGMA LL *>

MODULE UnionFindTranscriptView;

<*NOWARN*> IMPORT TextPort, Rd, ZeusClass, Filter, TextEditVBT;
<*NOWARN*> IMPORT Fmt, ZFmt, Wr, ZeusPanel, UnionFindViewClass;
<*NOWARN*> IMPORT FormsVBT, VBT, View;

<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
    fv: FormsVBT.T := NIL;
    te: TextEditVBT.T := NIL;
  OVERRIDES
    init       := TViewInit;
    install    := TViewInstall;
    delete     := TViewDelete;
    snapshot   := TViewSnapshot;
    restore    := TViewRestore;
    config     := TViewConfig;
    reactivity := TViewReactivity;
    startrun   := TViewStartrun;
    endrun     := TViewEndrun;
    oeSetup := Setup;
    oeNewSet := NewSet;
    oeFinishedSets := FinishedSets;
    oeStartFind := StartFind;
    oeEndFind := EndFind;
    oeStartDoFind := StartDoFind;
    oeStepUp := StepUp;
    oeFound := Found;
    oeStepDown := StepDown;
    oeChangeParent := ChangeParent;
    oeEndDoFind := EndDoFind;
    oeStartUnion := StartUnion;
    oeFoundFirst := FoundFirst;
    oeCompareRanks := CompareRanks;
    oeUnite := Unite;
    oeEndUnion := EndUnion;
  END;

PROCEDURE TViewInit (view: T): T =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "init");
    RETURN UnionFindViewClass.T.init (view, NIL);
  END TViewInit;

PROCEDURE Clear (<* UNUSED *> fv  : FormsVBT.T;
                 <* UNUSED *> name: TEXT;
                              cl  : REFANY;
                 <* UNUSED *> time: VBT.TimeStamp) =
  BEGIN
    TextPort.SetText(NARROW(cl, T).te.tp, "")
  END Clear;

PROCEDURE TViewInstall (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    view.fv := ZeusPanel.NewForm("UnionFindTranscriptView.fv");
    view.te := FormsVBT.GetVBT(view.fv, "transcript");
    TViewZTrace (view, "install");
    FormsVBT.AttachProc(view.fv, "clear", Clear, view);
    EVAL Filter.Replace (view, view.fv);
    UnionFindViewClass.T.install (view);
  END TViewInstall;

PROCEDURE TViewDelete (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "delete");
    UnionFindViewClass.T.delete (view);
   END TViewDelete;

PROCEDURE TViewSnapshot (view: T; wr: Wr.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "snapshot");
    UnionFindViewClass.T.snapshot (view, wr);
   END TViewSnapshot;

PROCEDURE TViewRestore (view: T; rd: Rd.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "restore");
    UnionFindViewClass.T.restore (view, rd);
   END TViewRestore;

PROCEDURE TViewConfig (
    view: T;
    state: ZeusClass.StateChange;
    o: ZeusClass.T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "config");
    UnionFindViewClass.T.config (view, state, o);
   END TViewConfig;

PROCEDURE TViewReactivity (view: T; <*UNUSED*> on: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace(view, "reactivity");
    UnionFindViewClass.T.reactivity (view, TRUE);
  END TViewReactivity;

PROCEDURE TViewStartrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "startrun");
    UnionFindViewClass.T.startrun (view);
   END TViewStartrun;

PROCEDURE TViewEndrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "endrun");
    UnionFindViewClass.T.endrun (view);
  END TViewEndrun;
event handling methods:

PROCEDURE Setup (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Setup ...")
       ELSE
          TViewTrace (view, "Setup "
          )
       END
    END
    END
  END Setup;

PROCEDURE NewSet (view: T;  nm: TEXT) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "NewSet ...")
       ELSE
          TViewTrace (view, "NewSet "
          & ZFmt.Text(nm)
          )
       END
    END
    END
  END NewSet;

PROCEDURE FinishedSets (view: T;  numSets: INTEGER; usesRanks: BOOLEAN) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "FinishedSets ...")
       ELSE
          TViewTrace (view, "FinishedSets "
          & ZFmt.Int(numSets)
          & " "
          & ZFmt.Bool(usesRanks)
          )
       END
    END
    END
  END FinishedSets;

PROCEDURE StartFind (view: T;  id: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartFind ...")
       ELSE
          TViewTrace (view, "StartFind "
          & ZFmt.Int(id)
          )
       END
    END
    END
  END StartFind;

PROCEDURE EndFind (view: T;  id: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EndFind ...")
       ELSE
          TViewTrace (view, "EndFind "
          & ZFmt.Int(id)
          )
       END
    END
    END
  END EndFind;

PROCEDURE StartDoFind (view: T;  id: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartDoFind ...")
       ELSE
          TViewTrace (view, "StartDoFind "
          & ZFmt.Int(id)
          )
       END
    END
    END
  END StartDoFind;

PROCEDURE StepUp (view: T;  child, parent: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StepUp ...")
       ELSE
          TViewTrace (view, "StepUp "
          & ZFmt.Int(child)
          & " "
          & ZFmt.Int(parent)
          )
       END
    END
    END
  END StepUp;

PROCEDURE Found (view: T;  id: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Found ...")
       ELSE
          TViewTrace (view, "Found "
          & ZFmt.Int(id)
          )
       END
    END
    END
  END Found;

PROCEDURE StepDown (view: T;  child, parent: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StepDown ...")
       ELSE
          TViewTrace (view, "StepDown "
          & ZFmt.Int(child)
          & " "
          & ZFmt.Int(parent)
          )
       END
    END
    END
  END StepDown;

PROCEDURE ChangeParent (view: T;  child, parent, root: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "ChangeParent ...")
       ELSE
          TViewTrace (view, "ChangeParent "
          & ZFmt.Int(child)
          & " "
          & ZFmt.Int(parent)
          & " "
          & ZFmt.Int(root)
          )
       END
    END
    END
  END ChangeParent;

PROCEDURE EndDoFind (view: T;  id: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EndDoFind ...")
       ELSE
          TViewTrace (view, "EndDoFind "
          & ZFmt.Int(id)
          )
       END
    END
    END
  END EndDoFind;

PROCEDURE StartUnion (view: T;  id1, id2: INTEGER; bothRoots: BOOLEAN) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartUnion ...")
       ELSE
          TViewTrace (view, "StartUnion "
          & ZFmt.Int(id1)
          & " "
          & ZFmt.Int(id2)
          & " "
          & ZFmt.Bool(bothRoots)
          )
       END
    END
    END
  END StartUnion;

PROCEDURE FoundFirst (view: T;  id1: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "FoundFirst ...")
       ELSE
          TViewTrace (view, "FoundFirst "
          & ZFmt.Int(id1)
          )
       END
    END
    END
  END FoundFirst;

PROCEDURE CompareRanks (view: T;  id1, id2: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "CompareRanks ...")
       ELSE
          TViewTrace (view, "CompareRanks "
          & ZFmt.Int(id1)
          & " "
          & ZFmt.Int(id2)
          )
       END
    END
    END
  END CompareRanks;

PROCEDURE Unite (view: T;  child, parent, pRank: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Unite ...")
       ELSE
          TViewTrace (view, "Unite "
          & ZFmt.Int(child)
          & " "
          & ZFmt.Int(parent)
          & " "
          & ZFmt.Int(pRank)
          )
       END
    END
    END
  END Unite;

PROCEDURE EndUnion (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EndUnion ...")
       ELSE
          TViewTrace (view, "EndUnion "
          )
       END
    END
    END
  END EndUnion;

PROCEDURE TViewZTrace (view: T; t: TEXT) =
  BEGIN
    IF view.fv # NIL THEN
      IF FormsVBT.GetBoolean(view.fv, "zeus") THEN
        TextPort.PutText(view.te.tp, "**zeus:  " & t & "\n");
        TextPort.Normalize(view.te.tp, LAST(INTEGER))
      END
    END
  END TViewZTrace;

PROCEDURE TViewTrace (view: T; t: TEXT) =
  BEGIN
    TextPort.PutText(view.te.tp, "--event: " & t & "\n");
    TextPort.Normalize(view.te.tp, LAST(INTEGER))
  END TViewTrace;

PROCEDURE TViewNew (): View.T =
  BEGIN
    RETURN NEW(T).init()
  END TViewNew;

BEGIN
  ZeusPanel.RegisterView
      (TViewNew, "UnionFind Transcript View", "UnionFind");
END UnionFindTranscriptView.

interface View is in: