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 a tagged record; declare an abstract
31 -- primitive operation and a non-abstract primitive operation of the
32 -- type. Derive an extended type from it, including a new component.
33 -- Use the derived type, the overriding operation and the inherited
34 -- operation to instantiate a generic package. The overriding operation
35 -- calls a new primitive operation and an inherited operation [so the
36 -- instantiation must get this sorted out correctly].
40 -- 06 Dec 94 SAIC ACVC 2.0
50 type Status_Enum
is (No_Status
, Handled
, Unhandled
, Pending
);
52 type Alert_Type
is abstract tagged record
58 subtype Serial_Number
is Integer range 0..Integer'last;
59 Serial_Num
: Serial_Number
:= 0;
61 procedure Handle
(A
: in out Alert_Type
) is abstract;
62 -- abstract primitive operation
64 -- the procedure Init would be _nice_ have this procedure be non_abstract
65 -- and create a "base" object with a "null" constraint. The language
66 -- will not allow this due to the restriction that an object of an
67 -- abstract type cannot be created. Hence Init must be abstract,
68 -- requiring any type derived directly from Alert_Type to declare
71 -- In light of this, I have changed init to a function to more closely
72 -- model the typical usage of OO features...
74 function Init
return Alert_Type
is abstract;
76 procedure No_Reply
(A
: in out Alert_Type
);
80 --=======================================================================--
82 package body C393008_0
is
84 procedure No_Reply
(A
: in out Alert_Type
) is
85 begin -- primitive operation, not abstract
86 TCTouch
.Touch
('A'); ------------------------------------------------- A
87 if A
.Status
= Handled
then
94 --=======================================================================--
97 -- pass in the Alert_Type object, including its
99 type Data_Type
is new C393008_0
.Alert_Type
with private;
100 -- note that Alert_Type is abstract, so it may not be
101 -- used as an actual parameter
102 with procedure Update
(P
: in out Data_Type
) is <>; -- generic formal
103 with function Initialize
return Data_Type
is <>; -- generic formal
108 procedure Modify
(Item
: in out Data_Type
);
113 --=======================================================================--
115 package body C393008_1
is
118 procedure Modify
(Item
: in out Data_Type
) is
120 TCTouch
.Touch
('B'); --------------------------------------------- B
127 --=======================================================================--
131 type Low_Alert_Type
is new C393008_0
.Alert_Type
with record
132 Serial
: C393008_0
.Serial_Number
;
135 procedure Serialize
(LA
: in out Low_Alert_Type
);
139 procedure Handle
(LA
: in out Low_Alert_Type
);
141 function Init
return Low_Alert_Type
;
144 package body C393008_2
is
145 procedure Serialize
(LA
: in out Low_Alert_Type
) is
146 begin -- new primitive operation
147 TCTouch
.Touch
('C'); ------------------------------------------------- C
148 C393008_0
.Serial_Num
:= C393008_0
.Serial_Num
+ 1;
149 LA
.Serial
:= C393008_0
.Serial_Num
;
154 function Init
return Low_Alert_Type
is
157 TCTouch
.Touch
('D'); ------------------------------------------------- D
159 TA
.Status
:= C393008_0
.No_Status
;
163 procedure Handle
(LA
: in out Low_Alert_Type
) is
164 begin -- overrides abstract inherited Handle
165 TCTouch
.Touch
('E'); ------------------------------------------------- E
168 LA
.Status
:= C393008_0
.Handled
;
176 package Alert_Utilities
is new
177 C393008_1
(Data_Type
=> Low_Alert_Type
,
178 Update
=> Handle
, -- Low_Alert's Handle
179 Initialize
=> Init
); -- inherited from Alert
181 Item
: Low_Alert_Type
;
183 use type C393008_0
.Status_Enum
;
187 Report
.Test
("C393008", "Check that an extended type can be derived "&
188 "from an abstract type");
191 if (Item
.Status
/= C393008_0
.No_Status
) or (Item
.Serial
/=1) then
192 Report
.Failed
("Wrong initialization");
194 TCTouch
.Validate
("DC", "Initialization Call");
196 Alert_Utilities
.Modify
(Item
);
197 if (Item
.Status
/= C393008_0
.Handled
) or (Item
.Serial
/= 3) then
198 Report
.Failed
("Wrong results from Modify");
200 TCTouch
.Validate
("BDCECA", "Generic Instance Call");