On Fri, 05 Jun 2009 08:51:38 +0400 Igor Gorbounov <[email protected]> wrote:
> Daniel Elstner пишет: > > Am Donnerstag, den 04.06.2009, 16:01 +0400 schrieb Igor Gorbounov: > > [...] > > > > As an example, I'm calling a method directly through a PMF here: > > http://github.com/danielkitta/kcio/blob/8edc530dbfe3d998c682da0218263d7c577f5c46/kc-keyboard/controller.cc#L162 > > > > > > Thanks, Daniel, it was helpfull, though it seems to be impossible to > transfer this > pointer to some outward object, knowing nothing about the class with > member function. Yes, but you can pass an opaque callback object to an outward object. The callback object which would comprise just a functor with an operator()() method containing: a) a pointer or reference to the particular object on which you want to invoke a method; b) a pointer to member function referencing the particular member function that you want to invoke; c) any arguments that you want to pass to the function call. Such an object is sometimes called a closure and is entirely opaque and self-contained. The outward object does not need to know what is in the closure, all it needs to do is call operator()() and whatever happens to be in the closure will execute. If in addition you have a template function to instantiate the callback objects, which (as it would be a template function) can use automatic type deduction, such callback objects become trivial to create and use. I have such a callback functor class which I sometimes use in preference to sigc::slot/sigc::mem_fun which I can e-mail you if you like. Chris _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
