with Calendar;
with String_Utilities;
with Io;
with Time_Utilities;
package body Job_Accounting is

    Start_Elapsed_Offset : constant Natural := 2;
    End_Elapsed_Offset : constant Natural := 20;
    Elapsed_Time_Length : constant Natural := 17;

    Cpu_Time_Offset : constant Natural := 39;
    Cpu_Time_End : constant Natural := 47;

    User_Session_Offset : constant Natural := 62;

    Disk_Wait_Offset : constant Natural := 48;
    Disk_Wait_End : constant Natural := 54;

    Jobs_Offset : constant Natural := 55;
    Jobs_End : constant Natural := 60;

    function "-" (T1, T2 : Calendar.Time) return Duration renames Calendar."-";

    package Sio renames Io;

    function Entry_Kind (Log_Entry : Entry_Type) return Kind is
    begin
        return Log_Entry.Entry_Kind;
    end Entry_Kind;

    function Elapsed_Time (Log_Entry : Entry_Type) return Duration is
    begin
        return Log_Entry.Elapsed_Time;
    end Elapsed_Time;

    function Cpu_Time (Log_Entry : Entry_Type) return Duration is
    begin
        return Log_Entry.Cpu_Time;
    end Cpu_Time;

    function User_Name (Log_Entry : Entry_Type) return String is
    begin
        return Unbounded.Image (Log_Entry.User_Name);
    end User_Name;

    function Session_Name (Log_Entry : Entry_Type) return String is
    begin
        return Unbounded.Image (Log_Entry.Session_Name);
    end Session_Name;

    function Jobs_Spawned (Log_Entry : Entry_Type) return Natural is
    begin
        return Log_Entry.Jobs;
    end Jobs_Spawned;

    function Disk_Io_Requests (Log_Entry : Entry_Type) return Natural is
    begin
        return Log_Entry.Disk_Waits;
    end Disk_Io_Requests;

    procedure Initialize (Log_File_Name : String;
                          Iter : out Iterator) is separate;
    procedure Next (Iter : in out Iterator) is
    begin
        Entry_List.Next (Entry_List.Iterator (Iter.all));
    end Next;

    function Value (Iter : Iterator) return Entry_Type is
    begin
        return Entry_List.Value (Entry_List.Iterator (Iter.all));
    end Value;

    function Done (Iter : Iterator) return Boolean is
    begin
        return Entry_List.Done (Entry_List.Iterator (Iter.all));
    end Done;
end Job_Accounting;