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 an extended type can be derived from an abstract type.
30 -- Declare an abstract type in the specification of a generic package.
31 -- Instantiate the package and derive an extended type from the abstract
32 -- (instantiated) type; override all abstract operations; use all
33 -- inherited operations;
37 -- 06 Dec 94 SAIC ACVC 2.0
38 -- 14 Oct 95 SAIC Fixed for ACVC 2.0.1
45 package Display_Devices
is
47 type Display_Device_Enum
is (None
, TTY
, Console
, Big_Screen
);
48 Display
: Display_Device_Enum
:= None
;
52 --=======================================================================--
56 type Generic_Status
is (<>);
58 type Serial_Type
is (<>);
60 package Alert_System
is
62 type Alert_Type
(Serial
: Serial_Type
) is abstract tagged record
63 Status
: Generic_Status
;
66 Next_Serial_Number
: Serial_Type
:= Serial_Type
'First;
68 procedure Handle
(A
: in out Alert_Type
) is abstract;
69 -- abstract operation - must be overridden after instantiation
71 procedure Display
( A
: Alert_Type
;
72 On
: Display_Devices
.Display_Device_Enum
);
73 -- primitive operation of Alert_Type
74 -- not required to be overridden
76 function Get_Serial_Number
(A
: Alert_Type
) return Serial_Type
;
77 -- primitive operation of Alert_Type
78 -- not required to be overridden
82 --=======================================================================--
84 package body Alert_System
is
86 procedure Display
( A
: in Alert_Type
;
87 On
: Display_Devices
.Display_Device_Enum
) is
89 Display_Devices
.Display
:= On
;
92 function Get_Serial_Number
(A
: Alert_Type
)
96 end Get_Serial_Number
;
100 --=======================================================================--
104 type Status_Kind
is (Green
, Yellow
, Red
);
105 type Serial_Number_Type
is new Integer range 1..Integer'Last;
107 subtype Msg_Str
is String (1..16);
108 Alert_Msg
: Msg_Str
:= "C393009 passed.";
111 package Alert_Pkg
is new Alert_System
(Status_Kind
, Serial_Number_Type
);
113 type New_Alert_Type
(Serial
: Serial_Number_Type
) is
114 new Alert_Pkg
.Alert_Type
(Serial
) with record
118 -- procedure Display is inherited by New_Alert_Type
120 -- function Get_Serial_Number is inherited by New_Alert_Type
121 procedure Handle
(NA
: in out New_Alert_Type
); -- must be overridden
122 procedure Init
(NA
: in out New_Alert_Type
); -- new primitive
124 NA
: New_Alert_Type
(Alert_Pkg
.Next_Serial_Number
);
125 -- New_Alert_Type is not abstract, so an object of that
126 -- type may be declared
130 package body NCC_1701
is
132 procedure Handle
(NA
: in out New_Alert_Type
) is
134 NA
.Message
:= Alert_Msg
;
135 Display
(NA
, On
=> Display_Devices
.TTY
);
138 procedure Init
(NA
: in out New_Alert_Type
) is -- new primitive operation
139 begin -- for New_Alert_Type
140 NA
:= (Serial
=> NA
.Serial
, Status
=> Green
, Message
=> (others => ' '));
146 use type Display_Devices
.Display_Device_Enum
;
150 Report
.Test
("C393009", "Check that an extended type can be derived " &
151 "from an abstract type");
154 if (Get_Serial_Number
(NA
) /= 1)
155 or (NA
.Status
/= Green
)
156 or (Display_Devices
.Display
/= Display_Devices
.None
) then
157 Report
.Failed
("Wrong Initialization");
161 if (Get_Serial_Number
(NA
) /= 1)
162 or (NA
.Status
/= Green
)
163 or (NA
.Message
/= Alert_Msg
)
164 or (Display_Devices
.Display
/= Display_Devices
.TTY
) then
165 Report
.Failed
("Wrong results from Handle");