home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 375.lha / IncrStorageManager_v1.0 / DynamicItem.mod < prev    next >
Text File  |  1990-05-02  |  3KB  |  134 lines

  1. IMPLEMENTATION MODULE DynamicItem;
  2.  
  3. (* Product: Incremental Storage Manager
  4.  
  5.    Version: 1.0
  6.  
  7.    Author:
  8.         Daniel B. Hankins
  9.         143 Montgomery Street
  10.         Poughkeepsie, NY 12601
  11.         dan-hankins@cup.portal.com
  12.  
  13.    Creation Date: 1989
  14.  
  15.    Release  Date: November 21, 1989
  16.  
  17.    Notice of Intellectual Property:
  18.         This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  19.    this program and all its parts in the public domain, under the definitions
  20.    and restrictions of United States law.
  21.  
  22.    History of Revisions:
  23.         None yet.
  24. *)
  25.  
  26. FROM SYSTEM      IMPORT ADDRESS, TSIZE;
  27.  
  28. IMPORT HandleCollection;
  29. IMPORT DynItem;
  30. IMPORT DynItemList;
  31.  
  32. TYPE
  33.   Object = POINTER TO Handle;
  34.   Handle = DynItem.Object;
  35.  
  36.  
  37. PROCEDURE New(Size: LONGCARD; InitIt: InitProc; TermIt: TermProc): Object;
  38. VAR
  39.   DItem:      Object;
  40.   ItemHandle: Handle;
  41. BEGIN
  42. (* New(Size, InitIt, Item) <-
  43.      DynItem.New(Size, ItemHandle),
  44.      New2(ItemHandle, InitIt, Item).
  45.    New2(ItemHandle, InitIt, Item) <-
  46.      DynItem.Nil(ItemHandle),
  47.      SetValue(Item,NIL).
  48.    New2(ItemHandle, InitIt, Item) <-
  49.      HandleCollection.NewHandle(DItem),
  50.      New3(ItemHandle, DItem, InitIt, Item).
  51.    New3(ItemHandle, DItem, InitIt, Item) <-
  52.      EqualValue(DItem, NIL),
  53.      DynItem.Kill(ItemHandle),
  54.      SetValue(Item, NIL).
  55.    New3(ItemHandle, DItem, InitIt, Item) <-
  56.      SetValue(DItem^, ItemHandle),
  57.      DynItem.SetHandle(DItem^, DItem),
  58.      DynItem.Percolate(DItem^),
  59.      DynItem.Percolate(DItem^),
  60.      DynItem.Init(DItem^, InitIt),
  61.      SetValue(Item, DItem).
  62. *)
  63.   ItemHandle := DynItem.New(Size, TermIt);
  64.   IF DynItem.Nil(ItemHandle) THEN
  65.     RETURN NIL;
  66.   END;
  67.  
  68.   DItem := HandleCollection.NewHandle();
  69.   IF DItem = NIL THEN
  70.     DynItem.Kill(ItemHandle);
  71.     RETURN NIL;
  72.   END;
  73.  
  74.   DItem^ := ItemHandle;
  75.   DynItem.SetHandle(DItem^, DItem);
  76.   DynItem.Percolate(DItem^);
  77.   DynItem.Percolate(DItem^);
  78.   DynItem.Init(DItem^, InitIt);
  79.  
  80.   RETURN DItem;
  81. END New;
  82.  
  83.  
  84. PROCEDURE Ref(Item: Object): Object;
  85. BEGIN
  86.   DynItem.Ref(Item^);
  87.   RETURN Item;
  88. END Ref;
  89.  
  90.  
  91. PROCEDURE Dispose(Item: Object);
  92. VAR
  93.   List: DynItemList.Object;
  94. BEGIN
  95.   List := DynItem.GetList(Item^);
  96.   IF DynItem.Dispose(Item^) THEN
  97.     HandleCollection.DisposeHandle(Item);
  98.   END;
  99.   DynItemList.Percolate(List);
  100. END Dispose;
  101.  
  102.  
  103. PROCEDURE Access(Item: Object): ADDRESS;
  104. BEGIN
  105.   RETURN DynItem.Access(Item^);
  106. END Access;
  107.  
  108.  
  109. PROCEDURE Set(Item:Object; NewDynItem: ADDRESS);
  110. BEGIN
  111.   Item^ := DynItem.Object(NewDynItem);
  112. END Set;
  113.  
  114.  
  115. PROCEDURE DisposeAll();
  116. BEGIN
  117.   DynItemList.DisposeAll();
  118.   HandleCollection.DisposeAll();
  119. END DisposeAll;
  120.  
  121.  
  122. PROCEDURE NilObject(): Object;
  123. BEGIN
  124.   RETURN NIL;
  125. END NilObject;
  126.  
  127.  
  128. PROCEDURE Nil(Item: Object): BOOLEAN;
  129. BEGIN
  130.   RETURN (Item = NIL);
  131. END Nil;
  132.  
  133. END DynamicItem.
  134.