|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 14336 (0x3800) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Associations_Generic_Enumerated_To_Enumerated, seg_0046d2
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« └─⟦this⟧
with Maps; package body Associations_Generic_Enumerated_To_Enumerated is Null_Association : constant String := ""; The_Separator : constant Character := '|'; function Is_Separator (This_Character : in Character) return Boolean is begin return This_Character = The_Separator; end Is_Separator; package Associations is new Maps (Is_Separator); function Is_Associated (This_Item : in Items; With_This_Key : in Keys) return Boolean is The_Associations : Associations.Map; The_Association : Associations.Mapping; The_Key : constant String := Keys'Image (With_This_Key); The_Item : constant String := Items'Image (This_Item); begin The_Associations := Associations.Create (From_Map_File => Associations_File); begin The_Association := Associations.Mapping_For The_Key, The_Associations); Associations.Reset (The_Association); while not Associations.Done (The_Association) loop if Associations.Current (The_Association) = The_Item then Associations.Dispose (The_Associations); return True; -- Found it. end if; Associations.Next (The_Association); end loop; Associations.Dispose (The_Associations); return False; exception when Associations.No_Mapping => Associations.Dispose (The_Associations); return False; end; exception when Associations.Io_Failure => raise Io_Failure; end Is_Associated; procedure Associate (This_Item : in Items; With_This_Key : in Keys; Unique : in Boolean := False) is The_Associations : Associations.Map; The_Association : Associations.Mapping; The_Key : constant String := Keys'Image (With_This_Key); The_Item : constant String := Items'Image (This_Item); Was_Modified : Boolean := False; Was_Already_Associated : Boolean := False; begin The_Associations := Associations.Create (From_Map_File => Associations_File); if Unique then -- Get rid of all associations to other keys. for Current_Key in Keys loop begin The_Association := Associations.Mapping_For (Keys'Image (Current_Key), The_Associations); Associations.Reset (The_Association); while not Associations.Done (The_Association) loop if Associations.Current (The_Association) = The_Item then if Current_Key = With_This_Key then Was_Already_Associated := True; exit; else Associations.Modify (The_Association, Null_Association); -- Turn off association. Was_Modified := True; end if; end if; Associations.Next (The_Association); end loop; if Was_Modified then Associations.Add (The_Association, The_Associations); end if; exception when Associations.No_Mapping => null; end; end loop; end if; if Was_Already_Associated then if Was_Modified then Associations.Save (Associations_File, The_Associations); end if; else -- Create the association. begin The_Association := Associations.Mapping_For (The_Key, The_Associations); Associations.Reset (The_Association); while not Associations.Done (The_Association) loop if Associations.Current (The_Association) = The_Item then Was_Already_Associated := True; exit; end if; Associations.Next (The_Association); end loop; if not Was_Already_Associated then Associations.Add (This_Field => The_Item, To_Mapping => The_Association, Using_Separator => The_Separator); Associations.Add (The_Association, The_Associations); Associations.Save (Associations_File, The_Associations); end if; exception when Associations.No_Mapping => -- Brand new key. Associations.Add (This_Mapping => The_Key & The_Separator & The_Item, To_Map => The_Associations); Associations.Save (Associations_File, The_Associations); end; end if; Associations.Dispose (The_Associations); exception when Associations.Io_Failure => raise Io_Failure; end Associate; procedure Dissociate (This_Item : in Items; From_This_Key : in Keys) is The_Associations : Associations.Map; The_Association : Associations.Mapping; The_Key : constant String := Keys'Image (From_This_Key); The_Item : constant String := Items'Image (This_Item); Was_Modified : Boolean := False; begin The_Associations := Associations.Create (From_Map_File => Associations_File); begin The_Association := Associations.Mapping_For (The_Key, The_Associations); Associations.Reset (The_Association); while not Associations.Done (The_Association) loop if Associations.Current (The_Association) = The_Item then Associations.Modify (The_Association, Null_Association); Was_Modified := True; end if; -- Keep going, might be duplicates. Associations.Next (The_Association); end loop; if Was_Modified then Associations.Add (The_Association, The_Associations); Associations.Save (Associations_File, The_Associations); end if; exception when Associations.No_Mapping => null; end; Associations.Dispose (The_Associations); exception when Associations.Io_Failure => raise Io_Failure; end Dissociate; function Items_Associated_With (This_Key : in Keys) return Item_Vector is The_Items : Item_Vector := (others => False); The_Associations : Associations.Map; The_Association : Associations.Mapping; The_Key : constant String := Keys'Image (This_Key); begin The_Associations := Associations.Create (From_Map_File => Associations_File); begin The_Association := Associations.Mapping_For (The_Key, The_Associations); Associations.Reset (The_Association); Associations.Next (The_Association); -- Ignre key field. while not Associations.Done (The_Association) loop declare Current_Item : constant String := Associations.Current (The_Association); begin if Current_Item /= Null_Association then The_Items (Items'Value (Current_Item)) := True; end if; exception when Constraint_Error => -- Bad entry in file. raise Bad_Entry; end; Associations.Next (The_Association); end loop; exception when Associations.No_Mapping => null; end; Associations.Dispose (The_Associations); return The_Items; exception when Associations.Io_Failure => raise Io_Failure; end Items_Associated_With; end Associations_Generic_Enumerated_To_Enumerated;
nblk1=d nid=0 hdr6=1a [0x00] rec0=1f rec1=00 rec2=01 rec3=044 [0x01] rec0=00 rec1=00 rec2=0d rec3=002 [0x02] rec0=1c rec1=00 rec2=02 rec3=022 [0x03] rec0=18 rec1=00 rec2=03 rec3=050 [0x04] rec0=18 rec1=00 rec2=04 rec3=024 [0x05] rec0=14 rec1=00 rec2=05 rec3=016 [0x06] rec0=1b rec1=00 rec2=06 rec3=006 [0x07] rec0=00 rec1=00 rec2=0c rec3=002 [0x08] rec0=15 rec1=00 rec2=07 rec3=062 [0x09] rec0=1f rec1=00 rec2=08 rec3=06e [0x0a] rec0=00 rec1=00 rec2=0b rec3=002 [0x0b] rec0=1e rec1=00 rec2=09 rec3=040 [0x0c] rec0=01 rec1=00 rec2=0a rec3=000 tail 0x217002a28815c671eea06 0x42a00088462061e03