with Unbounded_String;
with List_Generic;
package Job_Accounting is

    --  This package provides an abstract interface for getting information
    --  from the job accounting log files created by the system in the
    --  directory !Machine.Accounting.
    --
    --  It is the intention that Report procedures will be built on top on
    --  this package to format the information in usable ways, or higher level
    --  interfaces that may visit all accounting files a provide a summary
    --  of a particular users activity.
    --
    --  The information in the accounting files has the following fields from
    --  left to right:
    --
    --   1) A Job ('J') or Session ('S') indicator
    --
    --   2) The Start date and time for the job or session
    --
    --   3) The End data and time for the job or session
    --
    --   4) The CPU utilization is absolute time for the job or session
    --
    --   5) The number of Disk_waits
    --
    --   6) The number of Jobs spawned by a session  (This number is always
    --      a 1 for a job).
    --
    --   7) The User name and Session name for the job or Session.
    --      These are separated by a '.'.  System jobs are user "*SYSTEM"
    --      and session "*SYSTEM".
    --
    --

    type Entry_Type is private;

    type Kind is (Session, Job);

    function Entry_Kind (Log_Entry : Entry_Type) return Kind;

    function Elapsed_Time (Log_Entry : Entry_Type) return Duration;
    function Cpu_Time (Log_Entry : Entry_Type) return Duration;

    function User_Name (Log_Entry : Entry_Type) return String;
    function Session_Name (Log_Entry : Entry_Type) return String;

    function Jobs_Spawned (Log_Entry : Entry_Type) return Natural;
    function Disk_Io_Requests (Log_Entry : Entry_Type) return Natural;


    type Iterator is limited private;

    procedure Initialize (Log_File_Name : String; Iter : out Iterator);

    procedure Next (Iter : in out Iterator);
    function Value (Iter : Iterator) return Entry_Type;
    function Done (Iter : Iterator) return Boolean;

private

    package Unbounded is new Unbounded_String;

    type Entry_Type is
        record
            Entry_Kind : Kind;
            Jobs : Natural;
            Disk_Waits : Natural;
            Elapsed_Time : Duration;
            Cpu_Time : Duration;
            User_Name : Unbounded.Variable_String;
            Session_Name : Unbounded.Variable_String;
        end record;

    package Entry_List is new List_Generic (Entry_Type);

    type Iterator is access Entry_List.Iterator;

end Job_Accounting;