DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦36d50a1af⟧ TextFile

    Length: 2870 (0xb36)
    Types: TextFile
    Names: »B«

Derivation

└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Oo_Ada_Exception;
with Text_Io;
with Unchecked_Conversion;
with Unchecked_Deallocation;

package body Animal is

    type State is
        record
            Mass : Positive;
            Offspring_No : Natural := 0;
            Heir : Application.Object;
        end record;

    procedure Free is new Unchecked_Deallocation (State, State_Ptr);

    function Animal_View_Of is
       new Unchecked_Conversion
              (Source => Application.Object, Target => State_Ptr);


    function Application_View_Of is
       new Unchecked_Conversion (Source => State_Ptr,
                                 Target => Application.Object);


    function Create (Offspring_No : Natural := 0) return Object is
        This_Application : Animal.Application.Object;
        This_State_Ptr : State_Ptr;
    begin
        This_State_Ptr := new State;
        This_State_Ptr.Offspring_No := Offspring_No;
        This_Application := Application.Create (1);
        Application.Set_Heir (This_Application,
                              Application_View_Of (This_State_Ptr));

        return Object (This_Application);
    end Create;


    procedure Delete (This_Animal : in out Object;
                      Marker : Boolean := False) is separate;

    package Self is
        procedure Sleep (This_Animal : Object);
        procedure Eat (This_Animal : Object);
    end Self;


    package body Self is separate;


    procedure Sleep (This_Animal : Object;
                     Marker : Boolean := False) is separate;


    procedure Eat (This_Animal : Object) is separate;


    procedure Set_Mass (This_Animal : in out Object; Kg : Positive) is
    begin
        Part_Of (This_Animal).Mass := Kg;
    end Set_Mass;


    function Get_Mass (This_Animal : Object) return Positive is
    begin
        return Part_Of (This_Animal).Mass;
    end Get_Mass;


    procedure Image (This_Animal : Object) is
    begin
        Text_Io.Put_Line ("Animal is:");
        Text_Io.Put_Line ("   masse: " &
                          Positive'Image (Part_Of (This_Animal).Mass));
    end Image;


    function Part_Of (This_Animal : Object) return State_Ptr is  
        This_State_Ptr : State_Ptr;
    begin
        This_State_Ptr := Animal_View_Of
                             (S => Application.Get_Heir
                                      (Application.Object (This_Animal)));
        if This_State_Ptr = null then
            raise Oo_Ada_Exception.Part_Of_Error;
        else
            return This_State_Ptr;
        end if;
    end Part_Of;


    procedure Set_Heir (This_State_Ptr : in out State_Ptr;
                        Heir : Application.Object) is
    begin
        This_State_Ptr.Heir := Heir;
    end Set_Heir;


    function Get_Heir (This_State_Ptr : State_Ptr) return Application.Object is
    begin
        return This_State_Ptr.Heir;
    end Get_Heir;


end Animal;