Re: [gnet] Using GNet callbacks with C++
- From: Charles Kerr <charles rebelbase com>
- To: Michael Alger <gnet mm quex org>
- Cc: gnet gnetlibrary org
- Subject: Re: [gnet] Using GNet callbacks with C++
- Date: Tue, 22 Jul 2003 23:18:13 -0700
On Wed, Jul 23, 2003 at 01:03:20PM +0800, Michael Alger wrote:
>
> Is there any (clean) way of using GNet in a C++ application, where the
> callback functions are wanting to be member functions of a class? I've
> searched around for a C++ wrapper or any mention at all of how to do
> this, but to no avail.
>
> Would I be better off just looking for an alternative library, and if
> so, any recommendations? I mostly need Linux+Win32 support, and *BSD
> would be a bonus.
The same way one uses other GObject signals with C++ (and, in my case,
the way I use Motif :P with C++ in my day job) -- use private static
class methods to act as one-liner wrapper functions to the non-static
functions.
In your class, make a static private function with the signal's call
signature. Pass the this as the G_CALLBACK, and `this' as the user
data gpointer, to g_signal_connect().
In the static private function, cast the user data gpointer to your
object's type and invoke the real non-static method.
--
cheers,
Charles
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]