mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:46:00 +02:00
parent
4e96fe8fac
commit
49796e5151
@ -752,6 +752,43 @@
|
|||||||
NewInstance:=inherited NewInstance;
|
NewInstance:=inherited NewInstance;
|
||||||
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;
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
|
@ -226,6 +226,20 @@
|
|||||||
property RefCount : longint read frefcount;
|
property RefCount : longint read frefcount;
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user