|
Boost Users : |
From: Brian Braatz (brianb_at_[hidden])
Date: 2005-06-07 15:02:04
Forgive me. I reviewed your code- but I am having a hard time totally seeing what you are trying to do (by the code alone).
Allow me to offer a suggestion from what I understand of your description of the problem:
1- For your special callback, save it off somewhere as a boost.function<>
2- then call the boost.function<> you have saved before calling your signals
It is not clear to me if you want the "special" callback to also be in the signal. If so, you can add it (and the above still works)
Hope that helps
Brian
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Juho Mäkinen
> Sent: Monday, June 06, 2005 11:56 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] Problem with boost::signal. How to call just one
> slotin signal
>
> Hello.
>
> I'm having problems with boost::signal. I have a simple callback
> system:
>
> typedef boost::signal<void (const String &)> StringCallbacks;
> TSharedPtr<StringCallbacks> stringCallbacks;
>
> stringCallbacks contains void (Const String &) -callback functions.
> New callback functions are registered into the callback system with
> registerCallback -function:
>
> template<class VarType> class SettingUpdater {
> private:
> VarType & reference;
>
> SettingUpdater(VarType & var) : reference(var) { }
>
> public:
> void operator()(const String & setting)
> {
> // do someting irrelevant for the question here
> // with the reference -variable
> }
> };
>
> boost::signals::connection registerCallback(StringCallbacks::slot_type
> callback)
> {
> // PROBLEM: I'd like to call the callback once without calling every
> callback
> // which are possibly registered already into the signal before this.
>
> // Register the new callback into the signal.
> return stringCallbacks.get()->connect(callback);
> }
>
> The actual usage of registerCallback:
> int localVariable;
> registerCallback(SettingUpdater<int>(localVariable));
>
> Question:
> As you might already see above, I'd like to call the callback function
> once in the registerCallback function without calling every callback
> already registered in the stringCallbacks signal.
> I first tried something like
> String param = "foo";
> callback(param);
> but that won't compile.
>
> I also tried callback.get_slot_function()(param);
> That compiles, but it won't execute the operator() -function in
> SettingUpdater.
>
> Calling the signal will execute all callbacks registered, so the
> SettingUpdater
> function seems working. How I can execute the operator() function
> in SettingUpdater<> inside registerCallback function by the
> callback parameter passed to registerCallback function?
>
> Thanks in advance =)
>
> - Juho Mäkinen
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net