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

⟦e37f899ee⟧ Ada Source

    Length: 11264 (0x2c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Personnages, seg_0459b0

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 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;

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

    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;

end Personnages;

E3 Meta Data

    nblk1=a
    nid=3
    hdr6=c
        [0x00] rec0=23 rec1=00 rec2=01 rec3=014
        [0x01] rec0=20 rec1=00 rec2=09 rec3=00a
        [0x02] rec0=17 rec1=00 rec2=04 rec3=060
        [0x03] rec0=18 rec1=00 rec2=07 rec3=05e
        [0x04] rec0=1b rec1=00 rec2=0a rec3=05a
        [0x05] rec0=12 rec1=00 rec2=05 rec3=000
        [0x06] rec0=19 rec1=00 rec2=05 rec3=000
        [0x07] rec0=18 rec1=00 rec2=03 rec3=080
        [0x08] rec0=06 rec1=00 rec2=05 rec3=000
        [0x09] rec0=06 rec1=00 rec2=05 rec3=000
    tail 0x215420b3e864b7fc038ca 0x42a00088462060003
Free Block Chain:
  0x3: 0000  00 06 03 fc 00 00 00 00 35 20 20 20 20 66 75 6e  ┆        5    fun┆
  0x6: 0000  00 08 00 73 80 16 6e 67 5f 55 74 69 6c 69 74 69  ┆   s  ng_Utiliti┆
  0x8: 0000  00 02 03 fc 80 16 20 20 20 20 20 72 65 74 75 72  ┆           retur┆
  0x2: 0000  00 00 00 d5 80 03 6e 20 20 03 00 35 20 20 20 20  ┆      n    5    ┆