+ 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

@ -752,6 +752,43 @@
NewInstance:=inherited NewInstance;
TInterfacedObject(NewInstance).frefcount:=1;
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;
{****************************************************************************

View File

@ -226,6 +226,20 @@
property RefCount : longint read frefcount;
end;
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 }
PUnknown = ^IUnknown;