DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

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

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦f06c615bd⟧ Ada Source

    Length: 9216 (0x2400)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Personnages_A, seg_0488d7

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦5a81ac88f⟧ »Space Info Vol 1« 
        └─⟦this⟧ 

E3 Source Code



with Tree, List, String_Utilities, Unbounded_String;


package body Personnages_A is

    package Identifier is new Unbounded_String (1);

    subtype State_String is Identifier.Variable_String;

    package States_List is new List (Element => State_String);

    type Personnage is
        record
            Name : Identifier.Variable_String;
            Comment : Identifier.Variable_String;
            Position : Identifier.Variable_String;
            States : States_List.Object;
        end record;

    Current_Personnage : Personnage;

    --------------------

    function Equal (S1 : State_String; S2 : String) return Boolean is

    begin
        return String_Utilities.Equal (Identifier.Image (S1), S2);
    end Equal;

    function Find_State (Somebody_States : States_List.Object; A_State : String)
                        return Boolean is

    begin
        States_List.Go_First (Somebody_States);
        while not States_List.At_End (Somebody_States) loop
            if Equal (States_List.Get_Current_Element (Somebody_States),
                      A_State) then
                return True;
            end if;
            States_List.Go_Next (Somebody_States);
        end loop;
        return False;
    end Find_State;

    --------------------

    function "<" (Left, Right : Personnage) return Boolean is

    begin
        return String_Utilities.Less_Than
                  (Identifier.Image (Left.Name), Identifier.Image (Right.Name));
    end "<";

    function ">" (Left, Right : Personnage) return Boolean is

    begin
        return String_Utilities.Greater_Than
                  (Identifier.Image (Left.Name), Identifier.Image (Right.Name));
    end ">";

    package Personnages_Tree is new Tree (Element => Personnage,
                                          Nb_Preallocation_Node => 10);

    --------------------

    procedure Create (Name : String) is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        Personnages_Tree.Insert (A_Personnage);
    end Create;

    procedure Set_Comment (Name : String; Comment : String) is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        if Personnages_Tree.Find (A_Personnage) then  
            A_Personnage := Personnages_Tree.Get_Current_Element;
            A_Personnage.Comment := Identifier.Value (Comment);
            Personnages_Tree.Set_Current_Element (A_Personnage);
        end if;
    end Set_Comment;

    procedure Set_Position (Name : String; Position : String) is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        if Personnages_Tree.Find (A_Personnage) then
            A_Personnage := Personnages_Tree.Get_Current_Element;
            A_Personnage.Position := Identifier.Value (Position);
            Personnages_Tree.Set_Current_Element (A_Personnage);
        end if;
    end Set_Position;

    procedure Add_State (Name : String; State : String) is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        if Personnages_Tree.Find (A_Personnage) then
            A_Personnage := Personnages_Tree.Get_Current_Element;
            if not Find_State (A_Personnage.States, State) then
                States_List.Insert (A_Personnage.States,
                                    Identifier.Value (State));
                Personnages_Tree.Set_Current_Element (A_Personnage);
            end if;
        end if;
    end Add_State;

    procedure Remove_State (Name : String; State : String) is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        if Personnages_Tree.Find (A_Personnage) then
            A_Personnage := Personnages_Tree.Get_Current_Element;
            if Find_State (A_Personnage.States, State) then
                States_List.Remove_Current_Element (A_Personnage.States);
                Personnages_Tree.Set_Current_Element (A_Personnage);
            end if;
        end if;
    end Remove_State;

    function Exists (Name : String) return Boolean is
        A_Personnage : Personnage;
    begin  
        A_Personnage.Name := Identifier.Value (Name);
        return Personnages_Tree.Find (A_Personnage);
    end Exists;

    function Get_Comment (Name : String) return String is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        if Personnages_Tree.Find (A_Personnage) then
            A_Personnage := Personnages_Tree.Get_Current_Element;
            return Identifier.Image (A_Personnage.Comment);
        end if;
    end Get_Comment;

    function Get_Position (Name : String) return String is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        if Personnages_Tree.Find (A_Personnage) then
            A_Personnage := Personnages_Tree.Get_Current_Element;
            return Identifier.Image (A_Personnage.Position);
        end if;
    end Get_Position;

    function In_State (Name : String; State : String) return Boolean is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        if Personnages_Tree.Find (A_Personnage) then
            A_Personnage := Personnages_Tree.Get_Current_Element;
            return Find_State (A_Personnage.States, State);
        end if;
    end In_State;

    procedure Set_Current_Personnage (Name : String) is
        A_Personnage : Personnage;
    begin
        A_Personnage.Name := Identifier.Value (Name);
        if Personnages_Tree.Find (A_Personnage) then
            Current_Personnage := Personnages_Tree.Get_Current_Element;
        end if;
    end Set_Current_Personnage;

    procedure Go_First_State is
    begin
        States_List.Go_First (Current_Personnage.States);
    end Go_First_State;

    procedure Go_Next_State is
    begin
        States_List.Go_Next (Current_Personnage.States);
    end Go_Next_State;

    function At_End_State return Boolean is
    begin
        return States_List.At_End (Current_Personnage.States);
    end At_End_State;

    function Get_Current_State return String is
    begin
        return Identifier.Image (States_List.Get_Current_Element
                                    (Current_Personnage.States));
    end Get_Current_State;

end Personnages_A;

E3 Meta Data

    nblk1=8
    nid=0
    hdr6=10
        [0x00] rec0=24 rec1=00 rec2=01 rec3=038
        [0x01] rec0=00 rec1=00 rec2=08 rec3=004
        [0x02] rec0=1f rec1=00 rec2=02 rec3=04e
        [0x03] rec0=19 rec1=00 rec2=03 rec3=00c
        [0x04] rec0=18 rec1=00 rec2=04 rec3=00a
        [0x05] rec0=1b rec1=00 rec2=05 rec3=006
        [0x06] rec0=18 rec1=00 rec2=06 rec3=024
        [0x07] rec0=18 rec1=00 rec2=07 rec3=000
    tail 0x21545d33e865a3de28926 0x42a00088462060003