| 1 |
-- CA11016.A |
| 2 |
-- |
| 3 |
-- Grant of Unlimited Rights |
| 4 |
-- |
| 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 |
| 14 |
-- to do so. |
| 15 |
-- |
| 16 |
-- DISCLAIMER |
| 17 |
-- |
| 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. |
| 24 |
--* |
| 25 |
-- |
| 26 |
-- OBJECTIVE: |
| 27 |
-- Check that a child of a non-generic package can be a private generic |
| 28 |
-- package. Check that the private child instance can use its parent's |
| 29 |
-- declarations and operations. Check that the body of a public child |
| 30 |
-- package can instantiate its sibling private generic package. |
| 31 |
-- |
| 32 |
-- TEST DESCRIPTION: |
| 33 |
-- Declare a map abstraction in a package which manages basic physical |
| 34 |
-- map[s]. Declare a private generic child of this package which can be |
| 35 |
-- instantiated for any display device which has display locations of |
| 36 |
-- the physical map that can be characterized by any integer type, i.e., |
| 37 |
-- the intensity of the display point. |
| 38 |
-- |
| 39 |
-- Declare a public child of the physical map which specifies the |
| 40 |
-- display device. In the body of this child, declare an instance of |
| 41 |
-- its generic sibling to display the geographic locations. |
| 42 |
-- |
| 43 |
-- In the main program, check that the operations in the parent, public |
| 44 |
-- child and instance of the private child package perform as expected. |
| 45 |
-- |
| 46 |
-- |
| 47 |
-- CHANGE HISTORY: |
| 48 |
-- 06 Dec 94 SAIC ACVC 2.0 |
| 49 |
-- 17 Apr 96 SAIC ACVC 2.1: Added pragma Elaborate. |
| 50 |
-- |
| 51 |
--! |
| 52 |
|
| 53 |
-- Simulates map of physical features, i.e., desert, forest, or water. |
| 54 |
|
| 55 |
package CA11016_0 is |
| 56 |
type Map_Type is private; |
| 57 |
subtype Latitude is integer range 1 .. 9; |
| 58 |
subtype Longitude is integer range 1 .. 7; |
| 59 |
|
| 60 |
type Physical_Features is (Desert, Forest, Water); |
| 61 |
|
| 62 |
-- Use geographic database to initialize the basic map. |
| 63 |
|
| 64 |
procedure Initialize_Basic_Map (Map : in out Map_Type); |
| 65 |
|
| 66 |
function Get_Physical_Feature (Lat : Latitude; |
| 67 |
Long : Longitude; |
| 68 |
Map : Map_Type) return Physical_Features; |
| 69 |
|
| 70 |
private |
| 71 |
type Map_Type is array (Latitude, Longitude) of Physical_Features; |
| 72 |
Basic_Map : Map_Type; |
| 73 |
|
| 74 |
end CA11016_0; |
| 75 |
|
| 76 |
--==================================================================-- |
| 77 |
|
| 78 |
package body CA11016_0 is |
| 79 |
|
| 80 |
procedure Initialize_Basic_Map (Map : in out Map_Type) is |
| 81 |
-- Not a real initialization. Real application can use geographic |
| 82 |
-- database to create the basic map. |
| 83 |
|
| 84 |
begin |
| 85 |
for I in Latitude'first .. Latitude'last loop |
| 86 |
for J in 1 .. 2 loop |
| 87 |
Map (I, J) := Desert; |
| 88 |
end loop; |
| 89 |
for J in 3 .. 4 loop |
| 90 |
Map (I, J) := Forest; |
| 91 |
end loop; |
| 92 |
for J in 5 .. 7 loop |
| 93 |
Map (I, J) := Water; |
| 94 |
end loop; |
| 95 |
end loop; |
| 96 |
|
| 97 |
end Initialize_Basic_Map; |
| 98 |
-------------------------------------------------------- |
| 99 |
function Get_Physical_Feature (Lat : Latitude; |
| 100 |
Long : Longitude; |
| 101 |
Map : Map_Type) |
| 102 |
return Physical_Features is |
| 103 |
begin |
| 104 |
return (Map (Lat, Long)); |
| 105 |
end Get_Physical_Feature; |
| 106 |
-------------------------------------------------------- |
| 107 |
|
| 108 |
begin |
| 109 |
-- Initialize a basic map. |
| 110 |
Initialize_Basic_Map (Basic_Map); |
| 111 |
|
| 112 |
end CA11016_0; |
| 113 |
|
| 114 |
--==================================================================-- |
| 115 |
|
| 116 |
-- Private generic child package of physical map. This generic package may |
| 117 |
-- be instantiated for any display device which has display locations |
| 118 |
-- (latitude, longitude) that can be characterized by an integer value. |
| 119 |
-- For example, the intensity of the display point might be so characterized. |
| 120 |
-- It can be instantiated for any desired range of values (which would |
| 121 |
-- correspond to the range accepted by the display device). |
| 122 |
|
| 123 |
|
| 124 |
private |
| 125 |
|
| 126 |
generic |
| 127 |
|
| 128 |
type Display_Value is range <>; -- Any display feature that is |
| 129 |
-- represented by an integer. |
| 130 |
|
| 131 |
package CA11016_0.CA11016_1 is |
| 132 |
|
| 133 |
function Get_Display_Value (Lat : Latitude; |
| 134 |
Long : Longitude; |
| 135 |
Map : Map_Type) return Display_Value; |
| 136 |
|
| 137 |
end CA11016_0.CA11016_1; |
| 138 |
|
| 139 |
|
| 140 |
--==================================================================-- |
| 141 |
|
| 142 |
|
| 143 |
package body CA11016_0.CA11016_1 is |
| 144 |
|
| 145 |
function Get_Display_Value (Lat : Latitude; |
| 146 |
Long : Longitude; |
| 147 |
Map : Map_Type) |
| 148 |
return Display_Value is |
| 149 |
begin |
| 150 |
case Get_Physical_Feature (Lat, Long, Map) is |
| 151 |
-- Parent's operation, |
| 152 |
when Forest => return (Display_Value'first); |
| 153 |
-- Parent's type. |
| 154 |
when Desert => return (Display_Value'last); |
| 155 |
-- Parent's type. |
| 156 |
when others => return |
| 157 |
( (Display_Value'last - Display_Value'first) / 2 ); |
| 158 |
-- NOTE: Results are truncated. |
| 159 |
end case; |
| 160 |
|
| 161 |
end Get_Display_Value; |
| 162 |
|
| 163 |
end CA11016_0.CA11016_1; |
| 164 |
|
| 165 |
|
| 166 |
--==================================================================-- |
| 167 |
|
| 168 |
-- Map display operation, public child of physical map. |
| 169 |
|
| 170 |
package CA11016_0.CA11016_2 is |
| 171 |
|
| 172 |
-- Super-duper Ultra Geographic Display Device (SDUGD) can display |
| 173 |
-- geographic locations with light intensity values ranging from 1 to 7. |
| 174 |
|
| 175 |
type Display_Val is range 1 .. 7; |
| 176 |
|
| 177 |
type Device_Color is (Brown, Blue, Green); |
| 178 |
|
| 179 |
type IO_Packet is |
| 180 |
record |
| 181 |
Lat : Latitude; -- Parent's type. |
| 182 |
Long : Longitude; -- Parent's type. |
| 183 |
Color : Device_Color; |
| 184 |
Intensity : Display_Val; |
| 185 |
end record; |
| 186 |
|
| 187 |
procedure Data_For_SDUGD (Lat : in Latitude; |
| 188 |
Long : in Longitude; |
| 189 |
Output_Packet : in out IO_Packet); |
| 190 |
|
| 191 |
end CA11016_0.CA11016_2; |
| 192 |
|
| 193 |
--==================================================================-- |
| 194 |
|
| 195 |
|
| 196 |
with CA11016_0.CA11016_1; -- Private generic sibling. |
| 197 |
pragma Elaborate (CA11016_0.CA11016_1); |
| 198 |
|
| 199 |
package body CA11016_0.CA11016_2 is |
| 200 |
|
| 201 |
-- Declare instance of the private generic sibling for |
| 202 |
-- an integer type that represents color intensity. |
| 203 |
|
| 204 |
package SDUGD is new CA11016_0.CA11016_1 (Display_Val); |
| 205 |
|
| 206 |
procedure Data_For_SDUGD (Lat : in Latitude; |
| 207 |
Long : in Longitude; |
| 208 |
Output_Packet : in out IO_Packet) is |
| 209 |
|
| 210 |
-- Simulates sending control information to a display device. |
| 211 |
-- Control information consists of latitude, longitude, a |
| 212 |
-- color, and an intensity. |
| 213 |
|
| 214 |
begin |
| 215 |
case Get_Physical_Feature (Lat, Long, Basic_Map) is |
| 216 |
-- Parent's operation. |
| 217 |
when Water => Output_Packet.Color := Blue; |
| 218 |
Output_Packet.Intensity := SDUGD.Get_Display_Value |
| 219 |
(Lat, Long, Basic_Map); |
| 220 |
-- Sibling's operation. |
| 221 |
when Forest => Output_Packet.Color := Green; |
| 222 |
Output_Packet.Intensity := SDUGD.Get_Display_Value |
| 223 |
(Lat, Long, Basic_Map); |
| 224 |
-- Sibling's operation. |
| 225 |
when others => Output_Packet.Color := Brown; |
| 226 |
Output_Packet.Intensity := SDUGD.Get_Display_Value |
| 227 |
(Lat, Long, Basic_Map); |
| 228 |
-- Sibling's operation. |
| 229 |
end case; |
| 230 |
|
| 231 |
end Data_For_SDUGD; |
| 232 |
|
| 233 |
end CA11016_0.CA11016_2; |
| 234 |
|
| 235 |
--==================================================================-- |
| 236 |
|
| 237 |
with CA11016_0.CA11016_2; -- Map display device operation, |
| 238 |
-- implicitly withs parent, physical map |
| 239 |
-- application. |
| 240 |
|
| 241 |
use CA11016_0.CA11016_2; -- Allows direct visibility to the simple |
| 242 |
-- name of CA11016_0.CA11016_2. |
| 243 |
|
| 244 |
with Report; |
| 245 |
|
| 246 |
procedure CA11016 is |
| 247 |
|
| 248 |
TC_Packet : IO_Packet; |
| 249 |
|
| 250 |
begin |
| 251 |
|
| 252 |
Report.Test ("CA11016", "Check that body of a public child package can " & |
| 253 |
"use its sibling private generic package " & |
| 254 |
"declarations and operations"); |
| 255 |
|
| 256 |
-- Simulate control information at coordinates 3 and 7 of the |
| 257 |
-- basic map for the SDUGD. |
| 258 |
|
| 259 |
Water_Display_Subtest: |
| 260 |
begin |
| 261 |
TC_Packet.Lat := 3; |
| 262 |
TC_Packet.Long := 7; |
| 263 |
|
| 264 |
-- Build color and light intensity of the basic map at |
| 265 |
-- latitude 3 and longitude 7. |
| 266 |
|
| 267 |
Data_For_SDUGD (TC_Packet.Lat, TC_Packet.Long, TC_Packet); |
| 268 |
|
| 269 |
if ( (TC_Packet.Color /= Blue) or |
| 270 |
(TC_Packet.Intensity /= 3) ) then |
| 271 |
Report.Failed ("Map display device contains " & |
| 272 |
"incorrect values for water subtest"); |
| 273 |
end if; |
| 274 |
|
| 275 |
end Water_Display_Subtest; |
| 276 |
|
| 277 |
-- Simulate control information at coordinates 2 and 1 of the |
| 278 |
-- basic map for the SDUGD. |
| 279 |
|
| 280 |
Desert_Display_Subtest: |
| 281 |
begin |
| 282 |
TC_Packet.Lat := 9; |
| 283 |
TC_Packet.Long := 2; |
| 284 |
|
| 285 |
-- Build color and light intensity of the basic map at |
| 286 |
-- latitude 9 and longitude 2. |
| 287 |
|
| 288 |
Data_For_SDUGD (TC_Packet.Lat, TC_Packet.Long, TC_Packet); |
| 289 |
|
| 290 |
if ( (TC_Packet.Color /= Brown) or |
| 291 |
(TC_Packet.Intensity /= 7) ) then |
| 292 |
Report.Failed ("Map display device contains " & |
| 293 |
"incorrect values for desert subtest"); |
| 294 |
end if; |
| 295 |
|
| 296 |
end Desert_Display_Subtest; |
| 297 |
|
| 298 |
-- Simulate control information at coordinates 8 and 4 of the |
| 299 |
-- basic map for the SDUGD. |
| 300 |
|
| 301 |
Forest_Display_Subtest: |
| 302 |
begin |
| 303 |
TC_Packet.Lat := 8; |
| 304 |
TC_Packet.Long := 4; |
| 305 |
|
| 306 |
-- Build color and light intensity of the basic map at |
| 307 |
-- latitude 8 and longitude 4. |
| 308 |
|
| 309 |
Data_For_SDUGD (TC_Packet.Lat, TC_Packet.Long, TC_Packet); |
| 310 |
|
| 311 |
if ( (TC_Packet.Color /= Green) or |
| 312 |
(TC_Packet.Intensity /= 1) ) then |
| 313 |
Report.Failed ("Map display device contains " & |
| 314 |
"incorrect values for forest subtest"); |
| 315 |
end if; |
| 316 |
|
| 317 |
end Forest_Display_Subtest; |
| 318 |
|
| 319 |
Report.Result; |
| 320 |
|
| 321 |
end CA11016; |