[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dlsym() and C++



Magnus Norddahl wrote:

> Quoting Bert Peers (rat@larian.com):
> > Anyway, Pierre has a point that the strong link C++ enforces
> > between interface and implementation is a problem.  From
> > what I've read about OLE, the COM model is a pretty
> > neat way around this.  It works by putting the functions
> > you can call in a separate object.  The actual object
> > containing the data then has only 1 member, which
> > returns a pointer to that interface sub-object.  Obviously,
> > this one-and-only member can be made so that it returns
> > a different pointer/interface according to a parameter,
> > which gives you inheritance and polymorphism all
> > in one shot.  It sounds neat (especially for M$  I guess
> > they ripped it somewhere :) though I'm not sure this
> > short explanation is sortof clear ;)
>
> I dislike the way COM works. When you upgrade your COM interface, you have
> to do a QueryInterface to get the new one. Not very nice. I hate it when
> using DirectX...

Keep in mind that DirectX is actually a VERY bad use of COM.
COM in itself is reasonably good although upgrading COM interfaces can
indeed be a mess. However, this setup was done with a reason. Thanks to
QueryInterface you know exactly what you can expect from some interface.
It is not possible to add nor remove functions so if you use the interface you
know that everything will be there and if you implement the interface you know
that you only have to implement what's in the interface.

The trick is to try to design your interface so that future enhancements can
be foreseen.

In Crystal Space we now use COM for integrating the several layers of
the engine (like 3D rasterizer, 2D driver, 3D engine, ...). This works very well and
we also ported this system to other OS'es (linux, OS/2, BeOS, Macintosh, DOS, ...)
so we can use COM everywhere now.

Greetings,

--
==============================================================================
Jorrit.Tyberghein@uz.kuleuven.ac.be, University Hospitals KU Leuven BELGIUM

"Bonsai!"
        -- (Terry Pratchett, Reaper Man)
==============================================================================