[fpc-devel] {$Interfaces Corba} and TInterfacedObject
Vincent Snijders
vsnijders at quicknet.nl
Thu Nov 29 13:15:35 CET 2007
Sergei Gorelkin schreef:
> Graeme Geldenhuys wrote:
>>
>> Beats me, I thought that might be needed for querying a object for
>> interfaces it supports... As far as CORBA is concerned, I'm just
>> shooting in the dark here... Information on CORBA usage is limited
>> and I can't find any FPC code examples to give me hints. It seems
>> quite useless having the Corba support in FPC, if everything related
>> to Interfaces requires COM methods.
>>
> Think of Corba-styled interfaces as about "interfaces without COM glue",
> not just as about "interfaces without refcounting". To get runtime
> typecasting features, you have to implement it yourself. OTOH, you are
> free to implement anything you want.
>
> As for non-refcounted interfaced base class, you may want to use
> TComponent. Of course, it has some overhead compared with
> TInterfacedObject, but its features are quite useful in almost every
> application.
Given:
type
TAddCommand = class(TBaseCommnad, ICommand)
<bla>
end;
Does the compiler store somewhere that that TAddCommand implements ICommand? I
assume it does the compile time check that TAddCommand implements all ICommands
methods, but is there something similar provided by the compiler (or RTTI) which can
be used to do something like
ACommnd := TAddCommand.Create;
if (ACommand is TBaseCommand) then
writeln('This works');
if (ACommand.InheritsFrom('TBaseCommand') then
writeln('This works');
if (ACommand is ICommand) then
writeln('I don't know if this works, but I would expect it if you consider
interfaces similar to abstract base classes');
if (ACommand.Implements(ICommand)) then
writeln('I don't know if this works, but it is similar to the InheritsFrom case');
Vincent
More information about the fpc-devel
mailing list