TAggregatedObject

[Properties (by Name)][Methods (by Name)][Events (by Name)]

Aggregated object

Declaration

Source position: objpash.inc line 318

Type
  TAggregatedObject = class (TObject)
  private
    fcontroller : Pointer;
    function GetController : IUnknown;
  protected
    function QueryInterface(const iid: TGuid; out obj) : LongInt;
    function _AddRef : LongInt;
    function _Release : LongInt;
  public
    constructor Create(const aController: IUnknown);
    Controller : IUnknown;
  end
  ;

Description

TAggregatedObject implements an object whose lifetime is governed by an external object (or interface). It does not implement the IUnknown interface by itself, but delegates all methods to the controller object, as exposed in the Controller property. In effect, the reference count of the aggregated object is the same as that of it's controller, and additionally, all interfaces of the controller are exposed by the aggregated object.

Note that the aggregated object maintains a non-counted reference to the controller.

Aggregated objects should be used when using delegation to implement reference counted objects: the delegated interfaces can be implemented safely by TAggregatedObject descendents.

Members

Member Type Visibility Description
Controller Property public Controlling instance
Create Method public Create a new instance of TAggregatedObject
fcontroller Field private
GetController Method private
QueryInterface Method protected
_AddRef Method protected
_Release Method protected

Inheritance

Class Description
TAggregatedObject Aggregated object

See also

Name Description
IUnknown Basic interface for all COM-based interfaces
Controller Controlling instance
Create Create a new instance of TAggregatedObject