Jelajahi Sumber

+ TAggregatedObject, fixes #8149

git-svn-id: trunk@6089 -
florian 18 tahun lalu
induk
melakukan
49796e5151
2 mengubah file dengan 51 tambahan dan 0 penghapusan
  1. 37 0
      rtl/inc/objpas.inc
  2. 14 0
      rtl/inc/objpash.inc

+ 37 - 0
rtl/inc/objpas.inc

@@ -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;    
 
 
 {****************************************************************************

+ 14 - 0
rtl/inc/objpash.inc

@@ -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;