[fpc-pascal] corba interfaces - is/as not working properly

Martin Schreiber mse00000 at gmail.com
Thu Sep 29 07:42:33 CEST 2016


On Wednesday 28 September 2016 21:40:39 Lars wrote:
> On Wed, September 28, 2016 2:24 am, Graeme Geldenhuys wrote:
> > On 2016-09-28 08:38, David Emerson wrote:
> >> I'm testing out CORBA interfaces before changing all my code to use
> >> them (I would prefer not to have managed types for interfaces).
> >
> > I've been using CORBA style interfaces for years,
>
> Curious, where do corba interfaces come in handy ?

Assume there is a support-function or -class, for example TStatFiler from 
MSEgui, which stores and reads values to/from streams. It must call the 
appropriate read and write functions in the client classes. It is possible to 
define the functions in a common ancestor of the clients as "virtual 
abstract" which enforces a single client-class hierarchy which often is 
impossible to achieve.
The solution are interfaces but not the default COM-interfaces with their 
reference counting nightmare but the not reference counted CORBA-interfaces - 
which is a wrong name BTW because they have nothing to do with CORBA.

Clients of TStatReader/TStatWriter must implement the interface:
"
 istatfile = interface(iobjectlink)[miid_istatfile]
  procedure dostatread(const reader: tstatreader);
  procedure dostatwrite(const writer: tstatwriter);
  procedure statreading;
  procedure statread;
  function getstatvarname: msestring;
  function getstatpriority: integer;
 end;
"
iobjectlink provides basic object communication functionality:
"
 iobjectlink = interface(inullinterface)
  procedure link(const source,dest: iobjectlink; valuepo: pointer = nil;
                        ainterfacetype: pointer = nil; once: boolean = false);
  procedure unlink(const source,dest: iobjectlink; valuepo: pointer = nil);
               //source = 1 -> dest destroyed
  procedure objevent(const sender: iobjectlink; const event: objecteventty);
  function getinstance: tobject;
 end;
"
inullinterface is an empty CORBA-style interface:
"
{$interfaces corba}
 inullinterface = interface
  //no referencecount
 end;
"
If a client registers at TStatFiler it provides its "istatfile" pointer which 
will be stored in a list in TStatFiler. TStatfiler will use this list in 
order to call the necessary functions and procedures of the clients if 
reading/writing has been triggered.

MSEgui extensively uses CORBA-interfaces.

Martin



More information about the fpc-pascal mailing list