I am making a Gui Library on top of SDL using C++. (Don't ask me why, I am just doing it to gain some knowledge out of practice in order to understand how Gui libraries are made.) And I want to make a signal connection system like gtk+ or wxWidgets...
I understand I can do this using function pointers. But how do I add the functions to the main loop?
Or Is there a better way to do this?
The simplest way is borrowing it from a library, for example
boost::signal2. The next best thing is implementing your own but borrowing most of the features from libraries like
boost::bind (to enable the connections) or using C++0x features that will simplify the generic connection of clients (
I would recommend that you use
boost and their
signals2 library, as there are many things that you can do wrong and are already solved there.