kdemm backends & Helix
Matthias Welwarsky
matze at stud.fbi.fh-darmstadt.de
Sat Sep 18 09:22:47 BST 2004
On Friday, 17. September 2004 20:14, Ryan Gammon wrote:
> You don't need dynamic_cast.
>
> In general, you'll have stuff like
>
> void someFunc (IUnknown* pUnk)
> {
> IKoos* pKoos = NULL;
>
> pUnk->QueryInterface(IID_KOOS, (void**) &pKoos)
> if(pKoos)
> {
> // Do stuff
> pKoos->Release();
> }
> }
>
> class CKoos : public IKoos;
>
> void CKoos::QueryInterface(IID iid, void** ppObj)
> {
> *ppObj = NULL;
> if(iid == IID_KOOS)
> {
> *ppObj = (IKoos*) this;
> }
> }
>
> ... so you're really using void*'s.
>
> >Something to do with casting
> >given an UID. Maybe someone can sched some light on this how this is
> >done in mozilla.
>
> It's basically like this in helix and mozilla. In mozilla, you have the
> ability to make calls between languages, so I can have a JavaScript
> implementation of CKoos, and use it via its C++ interface definition,
> IKoos, which is cool.
As a sidenote, this is also how plugins are accessed in Trolltechs Qtopia
environment. Basically, you are guaranteed that each plugin implements a
queryInterface() method which can be asked by means of a UUID: " do you
support this interface?". In case of a match, queryInterface() returns a
pointer to an instance implementing said interface, or a null pointer in case
of a mismatch. Of course you need to static_cast<> the pointer you receive.
You could also do this with a dynamic_cast, but experience has shown that RTTI
is not reliable with plugins on a number of platforms. I remember having
problems with KDE2 when trying to compile it on an Alpha with Compaqs native
compiler kit for linux.
regards,
matthias
--
Matthias Welwarsky
Fachschaft Informatik FH Darmstadt
Email: matze at stud.fbi.fh-darmstadt.de
"all software sucks equally, but some software is more equal"
More information about the kde-multimedia
mailing list