-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistrar-executive-library_units_request.adb
132 lines (110 loc) · 5.86 KB
/
registrar-executive-library_units_request.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Containers;
with Ada.Strings.Unbounded;
with Registrar.Registry;
with Registrar.Registration;
with Registrar.Subsystems;
with Registrar.Executive.Subsystems_Request;
package body Registrar.Executive.Library_Units_Request is
-----------
-- Image --
-----------
function Image (Order: Library_Units_Request_Order)
return String
is
use Ada.Strings.Unbounded;
use type Ada.Containers.Count_Type;
Image_String: Unbounded_String;
begin
Set_Unbounded_String
(Target => Image_String,
Source => "[Library_Units_Request_Order]" & New_Line
& "Requested Units:");
if Order.Requested_Units.Length = 0 then
Append (Source => Image_String,
New_Item => " NONE");
else
for Unit of Order.Requested_Units loop
Append (Source => Image_String,
New_Item => New_Line & "- " & Unit.Name.To_UTF8_String);
end loop;
end if;
return To_String (Image_String);
end Image;
-------------
-- Execute --
-------------
procedure Execute (Order: in out Library_Units_Request_Order) is
use Unit_Names;
use Registrar.Subsystems;
use Registrar.Library_Units;
use Registrar.Executive.Subsystems_Request;
package All_Library_Units renames Registrar.Registry.All_Library_Units;
SS_Req_Order: Subsystems_Request_Order;
SS_Reqs : Subsystem_Sets.Set
renames SS_Req_Order.Requested_Subsystems;
Requested_Units: Library_Unit_Sets.Set renames Order.Requested_Units;
begin
pragma Assert (not Order.Requested_Units.Is_Empty);
SS_Req_Order.Tracker := Registration.Entry_Progress'Access;
-- Build the Subsystem request set
for Unit of Order.Requested_Units loop
pragma Assert (Unit.State = Requested);
declare
SS_Request: Subsystem (AURA => True);
begin
SS_Request.Name := Unit_Name (Unit.Name.Subsystem_Name);
SS_Request.State := Requested;
SS_Reqs.Include (SS_Request);
end;
end loop;
-- Submit the subsystem requests
SS_Req_Order.Tracker.Increment_Total_Items;
Workers.Enqueue_Order (SS_Req_Order);
-- Include the unit requests
All_Library_Units.Union (Requested_Units);
end Execute;
end Registrar.Executive.Library_Units_Request;