mentor/derived/HashIE.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 Hash.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE HashIE;

<*NOWARN*> IMPORT HashViewClass, HashAlgClass, IntList, ZeusClass;
<*NOWARN*> IMPORT Zeus, Algorithm, HashFmt, FormsVBT, View, Thread;
<*NOWARN*> IMPORT AlgorithmClass;

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

TYPE
  SetupArgs = BRANDED REF RECORD
    data: FormsVBT.T;
    nBuckets: INTEGER;
  END;

  InsertArgs = BRANDED REF RECORD
    key: TEXT;
  END;

  FindArgs = BRANDED REF RECORD
    key: TEXT;
  END;

  DeleteArgs = BRANDED REF RECORD
    key: TEXT;
  END;

  CompareArgs = BRANDED REF RECORD
    bucket: INTEGER;
  END;

  CheckDeletableArgs = BRANDED REF RECORD
    bucket: INTEGER;
  END;

  CheckHashPositionArgs = BRANDED REF RECORD
    bucket: INTEGER;
  END;

  AddToBucketArgs = BRANDED REF RECORD
    key: TEXT;
    bucket: INTEGER;
  END;

  DeleteFromBucketArgs = BRANDED REF RECORD
    key: TEXT;
    bucket: INTEGER;
    markEmpty: BOOLEAN;
  END;

  ReportFindArgs = BRANDED REF RECORD
    item: TEXT;
  END;

  FindReportArgs = BRANDED REF RECORD
    buckets: IntList.T;
  END;

  StopReportFindArgs = BRANDED REF RECORD
  END;

  StopFindReportArgs = 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
    | HashViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | SetupArgs(varSetupArgs) => <*NOWARN*>
          view.oeSetup (
              varSetupArgs.data
                ,
              varSetupArgs.nBuckets
              )
      | InsertArgs(varInsertArgs) => <*NOWARN*>
          view.oeInsert (
              varInsertArgs.key
              )
      | FindArgs(varFindArgs) => <*NOWARN*>
          view.oeFind (
              varFindArgs.key
              )
      | DeleteArgs(varDeleteArgs) => <*NOWARN*>
          view.oeDelete (
              varDeleteArgs.key
              )
      | CompareArgs(varCompareArgs) => <*NOWARN*>
          view.oeCompare (
              varCompareArgs.bucket
              )
      | CheckDeletableArgs(varCheckDeletableArgs) => <*NOWARN*>
          view.oeCheckDeletable (
              varCheckDeletableArgs.bucket
              )
      | CheckHashPositionArgs(varCheckHashPositionArgs) => <*NOWARN*>
          view.oeCheckHashPosition (
              varCheckHashPositionArgs.bucket
              )
      | AddToBucketArgs(varAddToBucketArgs) => <*NOWARN*>
          view.oeAddToBucket (
              varAddToBucketArgs.key
                ,
              varAddToBucketArgs.bucket
              )
      | DeleteFromBucketArgs(varDeleteFromBucketArgs) => <*NOWARN*>
          view.oeDeleteFromBucket (
              varDeleteFromBucketArgs.key
                ,
              varDeleteFromBucketArgs.bucket
                ,
              varDeleteFromBucketArgs.markEmpty
              )
      | FindReportArgs(varFindReportArgs) => <*NOWARN*>
          view.ueFindReport (
              varFindReportArgs.buckets
              )
      | StopFindReportArgs(varStopFindReportArgs) => <*NOWARN*>
          view.ueStopFindReport (
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a HashViewClass, so just ignore *)
    END
  END OEDispatcher;

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

PROCEDURE Setup (
      initiator: Algorithm.T;
       data: FormsVBT.T; nBuckets: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupArgs
               , data := data
               , nBuckets := nBuckets
      );
      alg := NARROW(initiator, HashAlgClass.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 Insert (
      initiator: Algorithm.T;
       key: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(InsertArgs
               , key := key
      );
      alg := NARROW(initiator, HashAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfInsert);
      alg.stopAtEvent := alg.eventDataRec.stopAtInsert;
      alg.waitAtEvent := alg.eventDataRec.waitAtInsert;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Insert", OEDispatcher, zumeArgRec);
    END;
  END Insert;

PROCEDURE Find (
      initiator: Algorithm.T;
       key: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(FindArgs
               , key := key
      );
      alg := NARROW(initiator, HashAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfFind);
      alg.stopAtEvent := alg.eventDataRec.stopAtFind;
      alg.waitAtEvent := alg.eventDataRec.waitAtFind;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Find", OEDispatcher, zumeArgRec);
    END;
  END Find;

PROCEDURE Delete (
      initiator: Algorithm.T;
       key: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(DeleteArgs
               , key := key
      );
      alg := NARROW(initiator, HashAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfDelete);
      alg.stopAtEvent := alg.eventDataRec.stopAtDelete;
      alg.waitAtEvent := alg.eventDataRec.waitAtDelete;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Delete", OEDispatcher, zumeArgRec);
    END;
  END Delete;

PROCEDURE Compare (
      initiator: Algorithm.T;
       bucket: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(CompareArgs
               , bucket := bucket
      );
      alg := NARROW(initiator, HashAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfCompare);
      alg.stopAtEvent := alg.eventDataRec.stopAtCompare;
      alg.waitAtEvent := alg.eventDataRec.waitAtCompare;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Compare", OEDispatcher, zumeArgRec);
    END;
  END Compare;

PROCEDURE CheckDeletable (
      initiator: Algorithm.T;
       bucket: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(CheckDeletableArgs
               , bucket := bucket
      );
      alg := NARROW(initiator, HashAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfCheckDeletable);
      alg.stopAtEvent := alg.eventDataRec.stopAtCheckDeletable;
      alg.waitAtEvent := alg.eventDataRec.waitAtCheckDeletable;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "CheckDeletable", OEDispatcher, zumeArgRec);
    END;
  END CheckDeletable;

PROCEDURE CheckHashPosition (
      initiator: Algorithm.T;
       bucket: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(CheckHashPositionArgs
               , bucket := bucket
      );
      alg := NARROW(initiator, HashAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfCheckHashPosition);
      alg.stopAtEvent := alg.eventDataRec.stopAtCheckHashPosition;
      alg.waitAtEvent := alg.eventDataRec.waitAtCheckHashPosition;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "CheckHashPosition", OEDispatcher, zumeArgRec);
    END;
  END CheckHashPosition;

PROCEDURE AddToBucket (
      initiator: Algorithm.T;
       key: TEXT; bucket: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(AddToBucketArgs
               , key := key
               , bucket := bucket
      );
      alg := NARROW(initiator, HashAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfAddToBucket);
      alg.stopAtEvent := alg.eventDataRec.stopAtAddToBucket;
      alg.waitAtEvent := alg.eventDataRec.waitAtAddToBucket;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "AddToBucket", OEDispatcher, zumeArgRec);
    END;
  END AddToBucket;

PROCEDURE DeleteFromBucket (
      initiator: Algorithm.T;
       key: TEXT; bucket: INTEGER; markEmpty: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(DeleteFromBucketArgs
               , key := key
               , bucket := bucket
               , markEmpty := markEmpty
      );
      alg := NARROW(initiator, HashAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfDeleteFromBucket);
      alg.stopAtEvent := alg.eventDataRec.stopAtDeleteFromBucket;
      alg.waitAtEvent := alg.eventDataRec.waitAtDeleteFromBucket;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "DeleteFromBucket", OEDispatcher, zumeArgRec);
    END;
  END DeleteFromBucket;

PROCEDURE FindReport (
      initiator: Algorithm.T;
       buckets: IntList.T
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(FindReportArgs
               , buckets := buckets
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Update, 1,
                  "FindReport", OEDispatcher, zumeArgRec);
  END FindReport;

PROCEDURE StopFindReport (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(StopFindReportArgs
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Update, 1,
                  "StopFindReport", OEDispatcher, zumeArgRec);
  END StopFindReport;

PROCEDURE ReportFind (
      initiator: View.T;
       item: TEXT
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(ReportFindArgs
               , item := item
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Notify, 1,
                  "ReportFind", FEDispatcher, zumeArgRec);
  END ReportFind;

PROCEDURE StopReportFind (
      initiator: View.T;

    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(StopReportFindArgs
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Notify, 1,
                  "StopReportFind", FEDispatcher, zumeArgRec);
  END StopReportFind;

BEGIN
END HashIE.

interface View is in: