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

⟦602fce7d0⟧ Ada Source

    Length: 17408 (0x4400)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Rooms, seg_0459b2

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 Rooms 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 Communications is
        record
            Way : Identifier.Variable_String;
            Destination : Identifier.Variable_String;
            Mode : Mode_Choice;
            Visibility : Visibility_Choice;
            Comment : Identifier.Variable_String;
        end record;

    package Communications_List is new List (Element => Communications);

    type Room is
        record
            Name : Identifier.Variable_String;
            Comment : Identifier.Variable_String;
            States : States_List.Object;
            Communications : Communications_List.Object;
        end record;

    Current_Room : Room;

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

    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 Find_Communication
                (Room_Communications : Communications_List.Object;
                 A_Way : String) return Boolean is
        A_Communication : Communications;
    begin
        Communications_List.Go_First (Room_Communications);
        while not Communications_List.At_End (Room_Communications) loop  
            A_Communication := Communications_List.Get_Current_Element
                                  (Room_Communications);
            if Equal (A_Communication.Way, A_Way) then
                return True;
            end if;
            Communications_List.Go_Next (Room_Communications);
        end loop;
        return False;
    end Find_Communication;

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

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

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

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

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

    package Rooms_Tree is new Tree
                                 (Element => Room, Nb_Preallocation_Node => 10);

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

    procedure Create (Name : String) is
        A_Room : Room;
    begin
        A_Room.Name := Identifier.Value (Name);
        Rooms_Tree.Insert (A_Room);
    end Create;

    procedure Set_Comment (Name : String; Comment : String) is
        A_Room : Room;
    begin
        A_Room.Name := Identifier.Value (Name);
        if Rooms_Tree.Find (A_Room) then  
            A_Room := Rooms_Tree.Get_Current_Element;
            A_Room.Comment := Identifier.Value (Comment);
            Rooms_Tree.Set_Current_Element (A_Room);
        end if;
    end Set_Comment;

    function Get_Comment (Name : String) return String is
        A_Room : Room;
    begin
        A_Room.Name := Identifier.Value (Name);
        if Rooms_Tree.Find (A_Room) then
            A_Room := Rooms_Tree.Get_Current_Element;
            return Identifier.Image (A_Room.Comment);
        end if;
    end Get_Comment;

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

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

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

    procedure Add_Communication
                 (Name : String; Way : String; Destination : String) is
        A_Room : Room;
        A_Communication : Communications;
    begin
        A_Room.Name := Identifier.Value (Name);
        if Rooms_Tree.Find (A_Room) then
            A_Room := Rooms_Tree.Get_Current_Element;
            if not Find_Communication (A_Room.Communications, Way) then
                A_Communication.Way := Identifier.Value (Way);
                A_Communication.Destination := Identifier.Value (Destination);
                Communications_List.Insert
                   (A_Room.Communications, A_Communication);
                Rooms_Tree.Set_Current_Element (A_Room);
            end if;
        end if;
    end Add_Communication;


    procedure Set_Communication_Mode
                 (Name : String; Way : String; Mode : Mode_Choice) is
        A_Room : Room;
        A_Communication : Communications;
    begin
        A_Room.Name := Identifier.Value (Name);
        if Rooms_Tree.Find (A_Room) then
            A_Room := Rooms_Tree.Get_Current_Element;
            if Find_Communication (A_Room.Communications, Way) then
                A_Communication := Communications_List.Get_Current_Element
                                      (A_Room.Communications);
                A_Communication.Mode := Mode;
                Communications_List.Set_Current_Element
                   (A_Room.Communications, A_Communication);
                Rooms_Tree.Set_Current_Element (A_Room);
            end if;
        end if;
    end Set_Communication_Mode;


    procedure Set_Communication_Visibility (Name : String;
                                            Way : String;
                                            Visibility : Visibility_Choice) is
        A_Room : Room;
        A_Communication : Communications;
    begin
        A_Room.Name := Identifier.Value (Name);
        if Rooms_Tree.Find (A_Room) then
            A_Room := Rooms_Tree.Get_Current_Element;
            if Find_Communication (A_Room.Communications, Way) then
                A_Communication := Communications_List.Get_Current_Element
                                      (A_Room.Communications);
                A_Communication.Visibility := Visibility;
                Communications_List.Set_Current_Element
                   (A_Room.Communications, A_Communication);
                Rooms_Tree.Set_Current_Element (A_Room);
            end if;
        end if;
    end Set_Communication_Visibility;


    procedure Set_Communication_Comment
                 (Name : String; Way : String; Comment : String) is
        A_Room : Room;
        A_Communication : Communications;
    begin
        A_Room.Name := Identifier.Value (Name);
        if Rooms_Tree.Find (A_Room) then
            A_Room := Rooms_Tree.Get_Current_Element;
            if Find_Communication (A_Room.Communications, Way) then
                A_Communication := Communications_List.Get_Current_Element
                                      (A_Room.Communications);
                A_Communication.Comment := Identifier.Value (Comment);
                Communications_List.Set_Current_Element
                   (A_Room.Communications, A_Communication);
                Rooms_Tree.Set_Current_Element (A_Room);
            end if;
        end if;
    end Set_Communication_Comment;

    procedure Set_Current_Room (Name : String) is
        A_Room : Room;
    begin
        A_Room.Name := Identifier.Value (Name);
        if Rooms_Tree.Find (A_Room) then
            Current_Room := Rooms_Tree.Get_Current_Element;
        end if;
    end Set_Current_Room;

    function Get_Current_Room return String is
    begin
        return Identifier.Image (Current_Room.Name);
    end Get_Current_Room;

    procedure First_Communication is  
    begin
        Communications_List.Go_First (Current_Room.Communications);
    end First_Communication;

    procedure Next_Communication is  
    begin
        Communications_List.Go_Next (Current_Room.Communications);
    end Next_Communication;

    function At_End_Communication return Boolean is  
    begin
        return Communications_List.At_End (Current_Room.Communications);
    end At_End_Communication;

    function Get_Communication_Way return String is
        A_Communication : Communications;
    begin
        A_Communication := Communications_List.Get_Current_Element
                              (Current_Room.Communications);
        return Identifier.Image (A_Communication.Way);
    end Get_Communication_Way;

    function Get_Communication_Destination return String is
        A_Communication : Communications;
    begin
        A_Communication := Communications_List.Get_Current_Element
                              (Current_Room.Communications);
        return Identifier.Image (A_Communication.Destination);
    end Get_Communication_Destination;

    function Get_Communication_Mode return Mode_Choice is
        A_Communication : Communications;
    begin
        A_Communication := Communications_List.Get_Current_Element
                              (Current_Room.Communications);
        return A_Communication.Mode;
    end Get_Communication_Mode;

    function Get_Communication_Visibility return Visibility_Choice is
        A_Communication : Communications;
    begin
        A_Communication := Communications_List.Get_Current_Element
                              (Current_Room.Communications);
        return A_Communication.Visibility;
    end Get_Communication_Visibility;

    function Get_Communication_Comment return String is
        A_Communication : Communications;
    begin
        A_Communication := Communications_List.Get_Current_Element
                              (Current_Room.Communications);
        return Identifier.Image (A_Communication.Comment);
    end Get_Communication_Comment;

end Rooms;

E3 Meta Data

    nblk1=10
    nid=4
    hdr6=1c
        [0x00] rec0=24 rec1=00 rec2=01 rec3=046
        [0x01] rec0=00 rec1=00 rec2=0c rec3=03c
        [0x02] rec0=1b rec1=00 rec2=06 rec3=022
        [0x03] rec0=1f rec1=00 rec2=08 rec3=040
        [0x04] rec0=1f rec1=00 rec2=09 rec3=00a
        [0x05] rec0=1a rec1=00 rec2=07 rec3=006
        [0x06] rec0=17 rec1=00 rec2=03 rec3=006
        [0x07] rec0=19 rec1=00 rec2=0e rec3=006
        [0x08] rec0=16 rec1=00 rec2=0b rec3=044
        [0x09] rec0=19 rec1=00 rec2=02 rec3=010
        [0x0a] rec0=1c rec1=00 rec2=0a rec3=06c
        [0x0b] rec0=01 rec1=00 rec2=10 rec3=00a
        [0x0c] rec0=17 rec1=00 rec2=0d rec3=06a
        [0x0d] rec0=09 rec1=00 rec2=0f rec3=000
        [0x0e] rec0=00 rec1=00 rec2=00 rec3=019
        [0x0f] rec0=00 rec1=00 rec2=00 rec3=000
    tail 0x215420b46864b7fc33e9a 0x42a00088462060003
Free Block Chain:
  0x4: 0000  00 05 00 0d 80 0a 6f 6e 20 47 65 74 5f 43 75 72  ┆      on Get_Cur┆
  0x5: 0000  00 00 00 04 80 01 74 01 02 20 20 20 20 20 20 20  ┆      t         ┆