[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    Re: kdemm backends & Helix
From:       Matthias Welwarsky <matze () stud ! fbi ! fh-darmstadt ! de>
Date:       2004-09-18 8:22:47
Message-ID: 200409181022.47280.matze () stud ! fbi ! fh-darmstadt ! de
[Download RAW message or body]

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@stud.fbi.fh-darmstadt.de

"all software sucks equally, but some software is more equal"
_______________________________________________
kde-multimedia mailing list
kde-multimedia@kde.org
https://mail.kde.org/mailman/listinfo/kde-multimedia
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic