From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: Sugestion to Multiple Inheritance
Date: Fri, 11 Jan 2002 17:04:39 -0500
Date: 2002-01-11T17:04:39-05:00 [thread overview]
Message-ID: <u3uo3b4r4oft6a@corp.supernews.com> (raw)
In-Reply-To: slrna3tf3u.kg.lutz@taranis.iks-jena.de
"Lutz Donnerhacke" <lutz@iks-jena.de> wrote in message
news:slrna3tf3u.kg.lutz@taranis.iks-jena.de...
> I have an several (at least two) interfaces with must be implemented
> by the end user (compiler should require implementation). All of them
> build a free(!) depedency tree. The simplest one is:
>
> A -> B B is an extended A and C is an extended A.
> | | D combines both extensions (requiring both).
> v v
> C -> D
You have to declare two "interface" types, B and C:
package P is
type AType is abstract tagged limited null record;
procedure A_Op (A : access AType) is abstract;
type BType is abstract new A with null record;
procedure B_Op (B : access BType) is abstract;
type BAccess is access all BType'Class;
type CType is abstract new A with null record;
procedure C_Op (C : access CType) is abstract;
type CAccess is access all CType'Class;
end P;
Now you want a D that you can view as either a B or a C:
with P; use P;
package Q is
type DType is limited private;
function BView (D : access DType) return BAccess;
function CView (D : access DType) return CAccess;
private
type D_BType (D : access DType) is new P.BType with null record;
procedure A_Op (BPart : access D_BType);
procedure B_Op (BPart : access D_BType);
type D_CType (D : access DType) is new P.CType with null record;
procedure A_Op (CPart : access D_CType);
procedure C_Op (CPart : access D_CType);
type DType is
limited record
BPart : aliased D_BType (DType'Access);
CPart : aliased D_CType (DType'Access);
end record;
end Q;
package body Q is
function BView (D : access DType) return BAccess is
begin
return D.BPart'Access;
end;
function CView (D : access DType) return CAccess is
begin
return D.CPart'Access;
end;
end Q;
Now you can use a D wherever you need a B or C, for example:
procedure Some_Op (B : access P.BType'Class);
declare
D : aliased DTYpe;
begin
Some_Op (BView (D'Access));
end;
next prev parent reply other threads:[~2002-01-11 22:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-11 10:20 Sugestion to Multiple Inheritance Lutz Donnerhacke
2002-01-11 17:21 ` Stephen Leake
2002-01-11 17:53 ` Lutz Donnerhacke
2002-01-11 19:57 ` Stephen Leake
2002-01-17 8:28 ` Lutz Donnerhacke
2002-01-17 14:31 ` Stephen Leake
2002-01-17 14:54 ` Lutz Donnerhacke
2002-01-17 20:52 ` Jim Rogers
2002-01-11 18:07 ` Mark Lundquist
2002-01-11 18:14 ` Richard Riehle
2002-01-11 20:56 ` Hyman Rosen
2002-01-12 7:35 ` Richard Riehle
2002-01-13 6:37 ` Hyman Rosen
2002-01-14 13:58 ` John English
2002-01-14 16:27 ` Ole-Hjalmar Kristensen
2002-01-12 2:09 ` Will
2002-01-11 22:04 ` Matthew Heaney [this message]
2002-01-15 15:32 ` Hyman Rosen
2002-01-15 16:03 ` Lutz Donnerhacke
2002-01-18 19:03 ` Matthew Heaney
2002-01-21 11:23 ` Lutz Donnerhacke
2002-01-21 16:43 ` Brian Rogoff
2002-01-21 17:00 ` Lutz Donnerhacke
2002-01-22 16:55 ` Brian Rogoff
2002-01-23 8:58 ` Dmitry A. Kazakov
2002-01-25 0:09 ` Brian Rogoff
2002-01-28 16:23 ` Dmitry A. Kazakov
2002-01-12 0:28 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox