with Text_Io;
use Text_Io;

--  This package abstractio I/O operations on the Statistics files
--  defined in LIST_STATISTICS.  It is a consequence of Ada that
--  such procedures must be defined for any structured types.
--  The package encapsulates details about file contents, layout, etc.

package Io_Package is

    -- Constants

    Columns : constant := 120;  -- must = SCHEMA.DESCRIPTION_LENGTH
    Unit_Name_Length : constant := 6;  -- must agree with SCHEMA.NAME_LENGTH
    Max_File_Length : constant := 6;
    C_Header : constant String :=
       " Name            Elapsed/CPU  Code/Data  Comments";
    R_Header : constant String :=
       " Name   Event    Elapsed/CPU  Code/Data  Comments";
    I_Header : constant String :=
       " Name   Event    Elapsed/CPU             Comments";

    --  Basic types
    type Choice_Type is (Start_Rec, Com_Rec, Stop_Rec);
    subtype Name_Type is String (1 .. Unit_Name_Length);
    subtype Size_Type is Natural;  -- integer bytes
    subtype Comment_Length is Natural range 0 .. Columns;
    subtype File_Name_Type is String (1 .. Max_File_Length);

    Blank_Unit_Name : Name_Type := (others => ' ');
    Blank_File_Name : File_Name_Type := (others => ' ');

    --  Structured types
    type File_Record_Type is
        record
            File_Exists : Boolean := False;
            File_Name : File_Name_Type := Blank_File_Name;
            Internal_Name : Text_Io.File_Type;
        end record;

    type Compilation_Record_Type (Len : Comment_Length := 0) is
        record
            Test_Name : Name_Type := Blank_Unit_Name;
            Total_Elapsed_Time : Duration := 0.0;
            Total_Cpu_Time : Duration := 0.0;
            Object_Code_Size : Size_Type := 0;
            Comments : String (1 .. Len) := (others => ' ');
        end record;

    type Run_Time_Record_Type (Len : Comment_Length := 0) is
        record
            Test_Name : Name_Type := Blank_Unit_Name;
            Total_Elapsed_Time : Duration := 0.0;
            Total_Cpu_Time : Duration := 0.0;
            Memory_Code_Size : Size_Type := 0;
            Memory_Data_Size : Size_Type := 0;
            Comments : String (1 .. Len) := (others => ' ');
        end record;

    type Instrumentation_Record_Type (Len : Comment_Length := 10) is
        record
            Test_Name : Name_Type := Blank_Unit_Name;
            Ident : Choice_Type := Start_Rec;
            Elapsed_Time : Duration := 0.0;
            Elapsed_Cpu_Time : Duration := 0.0;
            Comments : String (1 .. Len) := (others => ' ');
        end record;

    -- File I/O Operations

    procedure Get_File_Name (File : in out File_Record_Type);
    procedure Open_File (File : in out File_Record_Type;
                         Mode : in Text_Io.File_Mode := In_File);
    procedure Close_File (File : in out File_Record_Type);
    procedure File_Status (File : in File_Record_Type);

    -- Compilation I/O

    procedure Get (File : in File_Type; Value : out Compilation_Record_Type);
    procedure Put (File : in File_Type := Current_Output;
                   Value : in Compilation_Record_Type);

    -- Run Time I/O

    procedure Get (File : in File_Type; Value : out Run_Time_Record_Type);
    procedure Put (File : in File_Type := Current_Output;
                   Value : in Run_Time_Record_Type);

    -- Instrumentation I/O

    procedure Get (File : in File_Type;
                   Value : out Instrumentation_Record_Type);
    procedure Put (File : in File_Type := Current_Output;
                   Value : in Instrumentation_Record_Type);

end Io_Package;
--**********************************************************************