I have a class containing a large number (~100 or more) signals with varying signatures:
class MyClass
{
public:
boost::signals2::signal<void()>& Signal1();
boost::signals2::signal<int()>& Signal2();
boost::signals2::signal<void(std::string&)>& Signal3();
// etc.
// etc.
};
(Yes, its "yahw" - yet another HWND wrapper. Please refrain from commenting on the meaning of this plan ;-) )
Of course the signals are sparsely used, and I don't want to have data member for each unused signal.
Question:
How do I efficiently manage the creation and destruction of actually required signal instances?
My general idea is to add the signal to a map when the 1st slots connects, and to remove the signal when the last slot disconnects. However, boost::signals2::signal::connect etc. are not virtual, so inheriting a custom signal class does not work the naive way. How can I track slots connecting / disconnecting?