Class inheritance, although on the surface looks like interface inheritance,
is actually quite different. A class inherits all members from its parent,
whereas interface inheritance merely guarantees that the new interface
implements the inherited interface as a subset.
IMHO, interface inheritance has no real value, because you can achieve the
same goal (of extending the parent interface) simply by declaring a NEW
interface. The implementor class then supports both interfaces. The parent
interface can still be passed to old code, and the new interface passed to
new code. To get the old interface from the one, just call QueryInterface.
So for you interface list, you only need to call QueryInterface to extract
an interface that your code needs.
> What is the equivelent for an Interface Type Reference as
> opposed to an
> Interface instance reference...
> I :Iunknown; // an interface instance reference
> X :?????; // is there a way of storing which type of interface we're
> interested in?
There is no such thing as an interface reference - use GUIDs.
> Since it's possible to ascertain if an interface IWhatEver is
> supported by
> I. Is it possible to store IWhatever
> in X so that we can ascertain if I supports X... I'm guessing
> it's going to
> come down to storing the GUID of
> IWhatEver and calling I.QueryInterface directly - in which
> case, how do you
> extract the GUID of an Interface
> type...
Here are a few clues:
g: TGUID
g := ISomeInterface;
Regards,
Dennis.
> -----Original Message-----
> > IUnknown
>
> Since again I think my question has been misanswered....
>
> the following works for objects
>
> TMyList = class(TObject)
> private
> FAccept :TClass;
> FItems :Array of TObject; // Simple array management used...
> function GetItems(Index :Integer):TObject;
> function GetCount:Integer;
> public
> property Items[Index :Integer]:TObject read GetItems; default;
> property Count:Integer read GetCount;
> property Accept :TClass read FAccept write FAccept;
> function Add(O :TObject):Boolean;
> procedure Delete(Index :Integer);
> constructor Create(Accept :TClass);
> destructor destroy; override;
> end;
>
> constructor TMyList.Create(Accept :TClass);
> begin
> inherited Create;
> FAccept := Accept;
> end;
>
> function TMyList.Add(O :TObject):Boolean;
> begin
> Result := (FAccept<>nil) and (O is FAccept);
> if Result then begin
> SetLength(FItems,Length(FItems)+1);
> FItems[High(FItems)] := O;
> end;
> end;
>
> How can this storage of a Class *Type* be done for
> interfaces... If it's
> been answered
> I don't understand how to use the information... Note that
> FAccept contains
> a class type
> which is not known at the time of writing this object...
>
> FAccept is a Class Reference as opposed to an Instance reference...
>
> O :TObject; // an instance reference;
> C :TClass; // a class reference
>
> What is the equivelent for an Interface Type Reference as
> opposed to an
> Interface instance reference...
>
> I :Iunknown; // an interface instance reference
> X :?????; // is there a way of storing which type of interface we're
> interested in?
>
> Since it's possible to ascertain if an interface IWhatEver is
> supported by
> I. Is it possible to store IWhatever
> in X so that we can ascertain if I supports X... I'm guessing
> it's going to
> come down to storing the GUID of
> IWhatEver and calling I.QueryInterface directly - in which
> case, how do you
> extract the GUID of an Interface
> type...
>
> --
> Aaron@home
>
>
> --------------------------------------------------------------
> -------------
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz