Package Name: fifo

Return to: Package List


-- =============================================================================
-- File    : fifo.ads                                                          =
-- Project : AMAF                                                              =
-- Version : 1.0.0                                                             =
-- Author  : M. A. van der Lugt                                                =
--                                                                             =
-- Copyright 1996 Marinus A. van der Lugt                                      =
--                                                                             =
-- History :                                                                   =
-- ----------------------------------------------------------------------------=


-- =============================================================================


-- Standard Ada packages

-- MacOS packages


with Constants_And_Types ;
-- =============================================================================

generic
   type Item is private ;

   Queue_Size : Constants_And_Types.Natural_16 ;
package Fifo is


-- =============================================================================


package CT renames Constants_And_Types ;


type Fifo is tagged limited private ;
Fifo_Is_Empty : exception ;


Fifo_Is_Full  : exception ;
procedure Push
  (This  : in out Fifo ;

   Value : in     Item) ;
procedure Pop
  (This  : in out Fifo ;

   Value :    out Item) ;

function Is_Empty (This : in Fifo) return boolean ;


function Is_Full (This : in Fifo) return boolean ;

private

type Queue is array (1 .. Queue_Size) of Item ;
type Fifo is tagged limited
   record
      Items      : Queue ;
      NOF_Items  : CT.Natural_16 := 0 ;
      Push_Index : CT.Natural_16 := 1 ;
      Pop_Index  : CT.Natural_16 := 1 ;

   end record ;
end Fifo ;