mentor/derived/UnionFindIE.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:50:48 PST 1995 by kalsow  
      modified on Sun Jun  5 21:59:57 PDT 1994 by mhb     
      modified on Wed Feb 17 16:46:47 PST 1993 by johnh   

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

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


<* PRAGMA LL *>

MODULE UnionFindIE;

<*NOWARN*> IMPORT ZeusClass, Zeus, UnionFindAlgClass, Algorithm;
<*NOWARN*> IMPORT UnionFindViewClass, View, Thread, AlgorithmClass;

<* FATAL Zeus.Error, Zeus.Locked *>
If you get either of these errors, contact a Zeus implementor.

TYPE
  SetupArgs = BRANDED REF RECORD
  END;

  NewSetArgs = BRANDED REF RECORD
    nm: TEXT;
  END;

  FinishedSetsArgs = BRANDED REF RECORD
    numSets: INTEGER;
    usesRanks: BOOLEAN;
  END;

  StartFindArgs = BRANDED REF RECORD
    id: INTEGER;
  END;

  EndFindArgs = BRANDED REF RECORD
    id: INTEGER;
  END;

  StartDoFindArgs = BRANDED REF RECORD
    id: INTEGER;
  END;

  StepUpArgs = BRANDED REF RECORD
    child: INTEGER;
    parent: INTEGER;
  END;

  FoundArgs = BRANDED REF RECORD
    id: INTEGER;
  END;

  StepDownArgs = BRANDED REF RECORD
    child: INTEGER;
    parent: INTEGER;
  END;

  ChangeParentArgs = BRANDED REF RECORD
    child: INTEGER;
    parent: INTEGER;
    root: INTEGER;
  END;

  EndDoFindArgs = BRANDED REF RECORD
    id: INTEGER;
  END;

  StartUnionArgs = BRANDED REF RECORD
    id1: INTEGER;
    id2: INTEGER;
    bothRoots: BOOLEAN;
  END;

  FoundFirstArgs = BRANDED REF RECORD
    id1: INTEGER;
  END;

  CompareRanksArgs = BRANDED REF RECORD
    id1: INTEGER;
    id2: INTEGER;
  END;

  UniteArgs = BRANDED REF RECORD
    child: INTEGER;
    parent: INTEGER;
    pRank: INTEGER;
  END;

  EndUnionArgs = BRANDED REF RECORD
  END;
Zeus calls the following to invoke vbt v's event handler:

<*NOWARN*> PROCEDURE OEDispatcher(v: ZeusClass.T; evt: REFANY) RAISES {Thread.Alerted} =
  <* LL <= VBT.mu *>
  (* LL = {} if event style is output, LL = VBT.mu if event style is update. *)
  BEGIN
    TYPECASE v OF
    | UnionFindViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | SetupArgs(varSetupArgs) => <*NOWARN*>
          view.oeSetup (
              )
      | NewSetArgs(varNewSetArgs) => <*NOWARN*>
          view.oeNewSet (
              varNewSetArgs.nm
              )
      | FinishedSetsArgs(varFinishedSetsArgs) => <*NOWARN*>
          view.oeFinishedSets (
              varFinishedSetsArgs.numSets
                ,
              varFinishedSetsArgs.usesRanks
              )
      | StartFindArgs(varStartFindArgs) => <*NOWARN*>
          view.oeStartFind (
              varStartFindArgs.id
              )
      | EndFindArgs(varEndFindArgs) => <*NOWARN*>
          view.oeEndFind (
              varEndFindArgs.id
              )
      | StartDoFindArgs(varStartDoFindArgs) => <*NOWARN*>
          view.oeStartDoFind (
              varStartDoFindArgs.id
              )
      | StepUpArgs(varStepUpArgs) => <*NOWARN*>
          view.oeStepUp (
              varStepUpArgs.child
                ,
              varStepUpArgs.parent
              )
      | FoundArgs(varFoundArgs) => <*NOWARN*>
          view.oeFound (
              varFoundArgs.id
              )
      | StepDownArgs(varStepDownArgs) => <*NOWARN*>
          view.oeStepDown (
              varStepDownArgs.child
                ,
              varStepDownArgs.parent
              )
      | ChangeParentArgs(varChangeParentArgs) => <*NOWARN*>
          view.oeChangeParent (
              varChangeParentArgs.child
                ,
              varChangeParentArgs.parent
                ,
              varChangeParentArgs.root
              )
      | EndDoFindArgs(varEndDoFindArgs) => <*NOWARN*>
          view.oeEndDoFind (
              varEndDoFindArgs.id
              )
      | StartUnionArgs(varStartUnionArgs) => <*NOWARN*>
          view.oeStartUnion (
              varStartUnionArgs.id1
                ,
              varStartUnionArgs.id2
                ,
              varStartUnionArgs.bothRoots
              )
      | FoundFirstArgs(varFoundFirstArgs) => <*NOWARN*>
          view.oeFoundFirst (
              varFoundFirstArgs.id1
              )
      | CompareRanksArgs(varCompareRanksArgs) => <*NOWARN*>
          view.oeCompareRanks (
              varCompareRanksArgs.id1
                ,
              varCompareRanksArgs.id2
              )
      | UniteArgs(varUniteArgs) => <*NOWARN*>
          view.oeUnite (
              varUniteArgs.child
                ,
              varUniteArgs.parent
                ,
              varUniteArgs.pRank
              )
      | EndUnionArgs(varEndUnionArgs) => <*NOWARN*>
          view.oeEndUnion (
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a UnionFindViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | UnionFindAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a UnionFindAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE Setup (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupArgs
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetup);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetup;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetup;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Setup", OEDispatcher, zumeArgRec);
    END;
  END Setup;

PROCEDURE NewSet (
      initiator: Algorithm.T;
       nm: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(NewSetArgs
               , nm := nm
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfNewSet);
      alg.stopAtEvent := alg.eventDataRec.stopAtNewSet;
      alg.waitAtEvent := alg.eventDataRec.waitAtNewSet;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "NewSet", OEDispatcher, zumeArgRec);
    END;
  END NewSet;

PROCEDURE FinishedSets (
      initiator: Algorithm.T;
       numSets: INTEGER; usesRanks: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(FinishedSetsArgs
               , numSets := numSets
               , usesRanks := usesRanks
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfFinishedSets);
      alg.stopAtEvent := alg.eventDataRec.stopAtFinishedSets;
      alg.waitAtEvent := alg.eventDataRec.waitAtFinishedSets;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "FinishedSets", OEDispatcher, zumeArgRec);
    END;
  END FinishedSets;

PROCEDURE StartFind (
      initiator: Algorithm.T;
       id: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StartFindArgs
               , id := id
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStartFind);
      alg.stopAtEvent := alg.eventDataRec.stopAtStartFind;
      alg.waitAtEvent := alg.eventDataRec.waitAtStartFind;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StartFind", OEDispatcher, zumeArgRec);
    END;
  END StartFind;

PROCEDURE EndFind (
      initiator: Algorithm.T;
       id: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(EndFindArgs
               , id := id
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfEndFind);
      alg.stopAtEvent := alg.eventDataRec.stopAtEndFind;
      alg.waitAtEvent := alg.eventDataRec.waitAtEndFind;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "EndFind", OEDispatcher, zumeArgRec);
    END;
  END EndFind;

PROCEDURE StartDoFind (
      initiator: Algorithm.T;
       id: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StartDoFindArgs
               , id := id
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStartDoFind);
      alg.stopAtEvent := alg.eventDataRec.stopAtStartDoFind;
      alg.waitAtEvent := alg.eventDataRec.waitAtStartDoFind;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StartDoFind", OEDispatcher, zumeArgRec);
    END;
  END StartDoFind;

PROCEDURE StepUp (
      initiator: Algorithm.T;
       child, parent: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StepUpArgs
               , child := child
               , parent := parent
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStepUp);
      alg.stopAtEvent := alg.eventDataRec.stopAtStepUp;
      alg.waitAtEvent := alg.eventDataRec.waitAtStepUp;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StepUp", OEDispatcher, zumeArgRec);
    END;
  END StepUp;

PROCEDURE Found (
      initiator: Algorithm.T;
       id: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(FoundArgs
               , id := id
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfFound);
      alg.stopAtEvent := alg.eventDataRec.stopAtFound;
      alg.waitAtEvent := alg.eventDataRec.waitAtFound;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Found", OEDispatcher, zumeArgRec);
    END;
  END Found;

PROCEDURE StepDown (
      initiator: Algorithm.T;
       child, parent: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StepDownArgs
               , child := child
               , parent := parent
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStepDown);
      alg.stopAtEvent := alg.eventDataRec.stopAtStepDown;
      alg.waitAtEvent := alg.eventDataRec.waitAtStepDown;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StepDown", OEDispatcher, zumeArgRec);
    END;
  END StepDown;

PROCEDURE ChangeParent (
      initiator: Algorithm.T;
       child, parent, root: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(ChangeParentArgs
               , child := child
               , parent := parent
               , root := root
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfChangeParent);
      alg.stopAtEvent := alg.eventDataRec.stopAtChangeParent;
      alg.waitAtEvent := alg.eventDataRec.waitAtChangeParent;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "ChangeParent", OEDispatcher, zumeArgRec);
    END;
  END ChangeParent;

PROCEDURE EndDoFind (
      initiator: Algorithm.T;
       id: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(EndDoFindArgs
               , id := id
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfEndDoFind);
      alg.stopAtEvent := alg.eventDataRec.stopAtEndDoFind;
      alg.waitAtEvent := alg.eventDataRec.waitAtEndDoFind;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "EndDoFind", OEDispatcher, zumeArgRec);
    END;
  END EndDoFind;

PROCEDURE StartUnion (
      initiator: Algorithm.T;
       id1, id2: INTEGER; bothRoots: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StartUnionArgs
               , id1 := id1
               , id2 := id2
               , bothRoots := bothRoots
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStartUnion);
      alg.stopAtEvent := alg.eventDataRec.stopAtStartUnion;
      alg.waitAtEvent := alg.eventDataRec.waitAtStartUnion;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StartUnion", OEDispatcher, zumeArgRec);
    END;
  END StartUnion;

PROCEDURE FoundFirst (
      initiator: Algorithm.T;
       id1: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(FoundFirstArgs
               , id1 := id1
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfFoundFirst);
      alg.stopAtEvent := alg.eventDataRec.stopAtFoundFirst;
      alg.waitAtEvent := alg.eventDataRec.waitAtFoundFirst;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "FoundFirst", OEDispatcher, zumeArgRec);
    END;
  END FoundFirst;

PROCEDURE CompareRanks (
      initiator: Algorithm.T;
       id1, id2: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(CompareRanksArgs
               , id1 := id1
               , id2 := id2
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfCompareRanks);
      alg.stopAtEvent := alg.eventDataRec.stopAtCompareRanks;
      alg.waitAtEvent := alg.eventDataRec.waitAtCompareRanks;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "CompareRanks", OEDispatcher, zumeArgRec);
    END;
  END CompareRanks;

PROCEDURE Unite (
      initiator: Algorithm.T;
       child, parent, pRank: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(UniteArgs
               , child := child
               , parent := parent
               , pRank := pRank
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfUnite);
      alg.stopAtEvent := alg.eventDataRec.stopAtUnite;
      alg.waitAtEvent := alg.eventDataRec.waitAtUnite;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Unite", OEDispatcher, zumeArgRec);
    END;
  END Unite;

PROCEDURE EndUnion (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(EndUnionArgs
      );
      alg := NARROW(initiator, UnionFindAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfEndUnion);
      alg.stopAtEvent := alg.eventDataRec.stopAtEndUnion;
      alg.waitAtEvent := alg.eventDataRec.waitAtEndUnion;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "EndUnion", OEDispatcher, zumeArgRec);
    END;
  END EndUnion;

BEGIN
END UnionFindIE.

interface View is in: