3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that, in the body of a protected object created by the execution
28 -- of an allocator, external calls to other protected objects via
29 -- the access type are correctly performed
32 -- Use a subset of the simulation of the freeway on-ramp described in
33 -- c940005. In this case an array of access types is built with pointers
34 -- to successive ramps. The external calls within the protected
35 -- objects are made via the index into the array. Routines which refer
36 -- to the "previous" ramp and the "next" ramp are exercised. (Note: The
37 -- first and last ramps are assumed to be dummies and no first/last
38 -- condition code is included)
42 -- 06 Dec 94 SAIC ACVC 2.0
53 type acc_Ramp
is access Ramp
;
55 subtype Ramp_Index
is integer range 1..4;
58 -- Weighted load given to each potential problem area and accumulated
59 type Load_Factor
is range 0..8;
60 Clear_Level
: constant Load_Factor
:= 0;
61 Moderate_Level
: constant Load_Factor
:= 3;
63 --================================================================
64 -- Only the Routines that are used in this test are shown
66 protected type Ramp
is
68 procedure Set_Index
(Index
: Ramp_Index
);
69 procedure Set_Local_Overload
(Sensor_Level
: Load_Factor
);
70 function Local_Overload
return Load_Factor
;
72 function Next_Ramp_Overload
return Load_Factor
;
76 This_Ramp
: Ramp_Index
;
78 Next_Ramp_Alert
: Boolean := false; -- Next Ramp is in trouble?
80 -- Current state of the various Sample Points
81 Local_State
: Load_Factor
:= Clear_Level
;
84 --================================================================
86 -- Build a set of Ramp objects and an array of pointers to them
88 Ramp_Array
: array (Ramp_Index
) of acc_Ramp
:= (Ramp_Index
=> new Ramp
);
90 --================================================================
91 protected body Ramp
is
93 procedure Set_Index
(Index
: Ramp_Index
) is
98 -- These Set/Clear routines are triggered by real-time sensors that
99 -- reflect traffic state
100 procedure Set_Local_Overload
(Sensor_Level
: Load_Factor
) is
102 if Local_State
= Clear_Level
then
103 -- Notify "previous" ramp to check this one for current state.
104 -- Subsequent changes in state will not send an alert
105 -- When the situation clears another routine performs the
106 -- all_clear notification. (not shown)
107 -- EXTERNAL CALL OF PROCEDURE FROM PROCEDURE
108 Ramp_Array
(This_Ramp
- 1).Notify
; -- index to previous ramp
110 Local_State
:= Sensor_Level
;
111 null; --::::: Start local meter if not already started
112 end Set_Local_Overload
;
114 function Local_Overload
return Load_Factor
is
119 -- This is notification from the next ramp that it is in
120 -- overload. With this provision we only need to sample the next
121 -- ramp during adverse conditions.
124 Next_Ramp_Alert
:= true;
127 function Next_Ramp_Overload
return Load_Factor
is
129 if Next_Ramp_Alert
then
130 -- EXTERNAL FUNCTION CALL FROM FUNCTION
131 -- Get next ramp's current state
132 return Ramp_Array
(This_Ramp
+ 1).Local_Overload
;
136 end Next_Ramp_Overload
;
139 --================================================================
145 Report
.Test
("C940011", "Protected Objects created by allocators: " &
146 "external calls via access types");
148 -- Initialize each Ramp
149 for i
in Ramp_Index
loop
150 Ramp_Array
(i
).Set_Index
(i
);
153 -- Test driver. This is ALL test control code
155 -- Simulate calls to the protected functions and procedures
156 -- external calls. (do not call the "dummy" end ramps)
159 if Ramp_Array
(2).Next_Ramp_Overload
/= Clear_level
then
160 Report
.Failed
("Primary call incorrect");
163 -- Call which results in an external procedure call via the array
164 -- index from within the protected object
165 Ramp_Array
(3).Set_Local_Overload
(Moderate_Level
);
167 -- Call which results in an external function call via the array
168 -- index from within the protected object
169 if Ramp_Array
(2).Next_Ramp_Overload
/= Moderate_level
then
170 Report
.Failed
("Secondary call incorrect");