+ TAggregatedObject, fixes #8149

git-svn-id: trunk@6089 -
This commit is contained in:
florian 2007-01-20 20:28:29 +00:00
parent 4e96fe8fac
commit 49796e5151
2 changed files with 51 additions and 0 deletions

View File

@ -753,6 +753,43 @@
TInterfacedObject(NewInstance).frefcount:=1; TInterfacedObject(NewInstance).frefcount:=1;
end; end;
{****************************************************************************
TAGGREGATEDOBJECT
****************************************************************************}
constructor TAggregatedObject.Create(const aController: IUnknown);
begin
inherited Create;
{ do not keep a counted reference to the controller! }
fcontroller := Pointer(aController);
end;
function TAggregatedObject.QueryInterface(
const iid : tguid;out obj) : longint;stdcall;
begin
Result := IUnknown(fcontroller).QueryInterface(iid, obj);
end;
function TAggregatedObject._AddRef : longint;stdcall;
begin
Result := IUnknown(fcontroller)._AddRef;
end;
function TAggregatedObject._Release : longint;stdcall;
begin
Result := IUnknown(fcontroller)._Release;
end;
function TAggregatedObject.GetController : IUnknown;
begin
Result := IUnknown(fcontroller);
end;
{**************************************************************************** {****************************************************************************
Exception Support Exception Support

View File

@ -227,6 +227,20 @@
end; end;
TInterfacedClass = class of TInterfacedObject; TInterfacedClass = class of TInterfacedObject;
TAggregatedObject = class(TObject)
private
fcontroller: Pointer;
function GetController: IUnknown;
protected
{ implement methods of IUnknown }
function QueryInterface(const iid : tguid;out obj) : longint;stdcall;
function _AddRef : longint;stdcall;
function _Release : longint;stdcall;
public
constructor Create(const aController: IUnknown);
property Controller : IUnknown read GetController;
end;
{ some pointer definitions } { some pointer definitions }
PUnknown = ^IUnknown; PUnknown = ^IUnknown;
PPUnknown = ^PUnknown; PPUnknown = ^PUnknown;