[opensource-dev] I could use a little help with boost and callbacks and stuff

Ricky kf6kjg at gmail.com
Sat Nov 12 18:43:00 PST 2011


Is something like:
std::bind1st(std::mem_fun(&MyClass::MyMethod), myParameter)
what you are looking for?

You can see working code using that on lines 350-390 of
https://bitbucket.org/kf6kjg/gsp-420-engine-design-graphics/src/120a2081bb2f/src/audio_core/AudioCore.cpp
(This was code I wrote while helping out another team in one of my classes.)

Boost's Bind function
(http://www.boost.org/doc/libs/1_47_0/libs/bind/bind.html) generalizes
the standard call I used, and so might be easier to use.  Here's the
same using Boost:
bind(&MyClass::MyMethod, myParameter)

I hope this helps,
Ricky
Cron Stardust

On Sat, Nov 12, 2011 at 1:54 PM, Lance Corrimal
<Lance.Corrimal at eregion.de> wrote:
> Hi there,
>
>
> I'm banging my head against a problem here...
> I want to add buttons to the toolboxes.
>
> The actuall adding is easy, but I have trouble figuring out what I
> need to do to register some callbacks into the classes I need.
>
> I have two classes that I need to "buttonize"... one represents the
> graphical UI for a set of new features, and that one I managed to set
> up as a toolbox button just fine.
>
> The other one is troublesome though. I need to establish a method that
> gets called (with no parameter, or a dummy), to toggle an internal
> switch in my class, and I need another callback, that returns the
> boolean value of that internal switch, to turn the button green or
> not. Think of a simple "on/off switch".
>
> What I can't figure out is what I actually have to do with my class to
> implement the callbacks properly, and what I have to pass to the
> function that registers the callback.
>
> Any hints/tips for me?
>
> thanks,
>
> LC
> _______________________________________________
> Policies and (un)subscribe information available here:
> http://wiki.secondlife.com/wiki/OpenSource-Dev
> Please read the policies before posting to keep unmoderated posting privileges
>


More information about the opensource-dev mailing list