|
Boost Users : |
Subject: [Boost-users] Extracting a boost::function from a boost::signals2::signal
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2012-07-19 17:31:26
Hello,
I would like to create an "Interceptor" class that can generically
receive a void-returning signal with n arguments (as something like a
boost::function<void()>) and, at runtime, decide whether the signal
will be delivered to the final slot. Or perhaps even deliver the
signal at some later time. Psuedocode might look like this:
class Interceptor
{
template<class Signal>
void Connect(Signal& signal, const Signal::slot_type& slot)
{
signal.connect_generic(slot, bind(&Interceptor::Dispatch, this, _1));
}
void Dispatch(const boost::function<void()>& Function)
{
if (DispatchNow())
{
Function();
}
else if (DispatchLater())
{
DispatchLater.push_back(Function);
}
}
};
Is such a thing possible?
Thank you,
Chris
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