[fpc-devel] {$Interfaces Corba} and TInterfacedObject

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Nov 29 12:05:24 CET 2007


On 29/11/2007, Joao Morais <post at joaomorais.com.br> wrote:
>
> Any class. Afaik corba interfaces doesn't implement a method ?
>


OK, I wrote a quick test app.  Added {$Interfaces Corba} in each unit
just to be save.

I declared two interfaces as follows:

type
  ICommand = interface
  ['{28D72102-D883-41A1-9585-D86B24D9C628}']
    procedure   Execute;
  end;


  ICommandHolder = interface
  ['{695BA6E1-1120-42D4-A2C3-54F98D5CDA46}']
    function    GetCommand: ICommand;
    procedure   SetCommand(ACommand: ICommand);
  end;


I then defined a class implementing ICommand as follows taking your
suggestion of using TObject:


  TAddCommand = class(TObject, ICommand)
  private
    FMemo: TfpgMemo;
  public
    constructor Create(AMemo: TfpgMemo); reintroduce;
    procedure   Execute;
  end;


I then wrote the following code to see if I could query for a
supported interface.

var
  cmd: ICommand;
  ins: TAddCommand;
begin
  ins := TAddCommand.Create(memName1);
  if Supports(ins, ICommand, cmd) then
  begin
    writeln('It worked');
    cmd.Execute;
  end;
  ins.Free;
end;


Well, the 'It worked' never appears and the cmd.Execute is never
fired, so it's still a mystery how CORBA interfaces work.  I'll see if
Delphi help maybe mentions something.


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-devel mailing list