unit uController;

interface

uses
  Sysutils, uAggregatedObj, uContainedObject;

type
  IController = interface
    ['{9238BE74-948B-4CAC-A14C-EA19DD8811E8}']
    function GetName(var sName: WideString): HResult; stdcall;
  end;

  TController = class(TInterfacedObject, IController, IAggInterface, IContainedInterface)
  private
    FAggObj : IAggInterface;
    FContained : IContainedInterface;
  public
    Constructor Create;
    DesTructor Destroy; override;
    function GetName(var sName: WideString): HResult; stdcall;

    property AggObj : IAggInterface read FAggObj implements IAggInterface;
    property cnObj : IContainedInterface read FContained implements IContainedInterface;
  end;

implementation

{ TController }

constructor TController.Create;
begin
  FAggObj := TAggregatedObj.Create(Self);
  FContained := TCnObject.Create(Self);
end;

destructor TController.Destroy;
begin
  FAggObj := nil;
  FContained := nil;
  inherited;
end;

function TController.GetName(var sName: WideString): HResult;
begin
  sName := 'I am the Controller!';
  Result := S_OK;
end;

end.
