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

⟦da17d4059⟧ TextFile

    Length: 3276 (0xccc)
    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 Plant;  
with Text_Io;
with Tomato;
with Unchecked_Conversion;
with Unchecked_Deallocation;


package body Vegetable is


    procedure Free is new Unchecked_Deallocation (State, State_Ptr);


    function Vegetable_View_Of is
       new Unchecked_Conversion (Source => Root.Object, Target => State_Ptr);


    function Root_View_Of is
       new Unchecked_Conversion (Source => State_Ptr, Target => Root.Object);


    function Create (Offspring : Natural) return Root.Object is
        This_Object : Root.Object;
        This_State_Ptr : State_Ptr;  
        Plant_State_Ptr : Plant.State_Ptr;
    begin
        This_State_Ptr := new State;
        This_State_Ptr.Offspring := Offspring;
        This_Object := Plant.Create (1);
        Plant_State_Ptr := Plant.Part_Of (This_Object);
        Plant.Set_Heir (Plant_State_Ptr, Root_View_Of (This_State_Ptr));

        return This_Object;
    end Create;


    procedure Delete (This_Object : in out Root.Object) is
        This_State_Ptr : State_Ptr := Part_Of (This_Object);
    begin
        case This_State_Ptr.Offspring is
            when 0 =>
                Free (This_State_Ptr);
                Plant.Delete (This_Object);
            when 1 =>
                Tomato.Delete (This_Object);
            when others =>
                raise Oo_Ada_Exception.Offspring_Error;
        end case;
    end Delete;


    procedure Set_Y (This_State : in out State; This_Y : Natural) is
    begin
        This_State.Y := This_Y;
    end Set_Y;


    function Get_Y (This_State : State) return Natural is
    begin
        return This_State.Y;

    end Get_Y;


    package Self is
        procedure Grow (This_Object : Root.Object; Marker : Boolean := False);
    end Self;


    package body Self is
        procedure Grow (This_Object : Root.Object; Marker : Boolean := False) is
        begin
            Plant.Grow (This_Object, True);
        end Grow;
    end Self;


    procedure Grow (This_Object : Root.Object; Marker : Boolean := False) is
        This_State_Ptr : State_Ptr := Part_Of (This_Object);
    begin
        case This_State_Ptr.Offspring is
            when 0 =>
                Self.Grow (This_Object);
            when 1 =>  
                if not Marker then
                    Tomato.Grow (This_Object);
                else
                    Self.Grow (This_Object);
                end if;
            when others =>
                raise Oo_Ada_Exception.Offspring_Error;
        end case;
    end Grow;


    function Part_Of (This_Object : Root.Object) return State_Ptr is
        This_State_Ptr : State_Ptr;
    begin
        This_State_Ptr := Vegetable_View_Of
                             (S => Plant.Get_Heir
                                      (Plant.Part_Of (This_Object)));
        if This_State_Ptr = null then
            raise Oo_Ada_Exception.Part_Of_Error;
        end if;
        return This_State_Ptr;
    end Part_Of;


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


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

end Vegetable;