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@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Juho Mäkinen Sent: Monday, June 06, 2005 11:56 PM To: boost-users@lists.boost.org 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
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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users