I've been using boost::signals all over and in each case it looks something like:
struct Window {
boost::signal<void (int, int)> onResized;
void Resize()
{
onResized(100, 100);
}
};
Then to make connections I have:
window->onResized.connect(bind(&Renderer::OnResized, r, _1, _2));
I have the signal in the public interface allows anyone to set up connections (which I want) but also allows anyone to fire off the signal (which I don't want).
The solution could be something like:
class Window {
boost::signal<void (int, int)> onResized;
public:
void ResizedConnect(boost::function<void (int, int)> f)
{
onResized.connect(f);
}
};
But it's more boilerplate stuff than I'd care for. Is there some simpler way this could be done? I've experimented trying to do this with templates but it gets messy with lots of signals.