I\'m not sure how to look for this online... I think they might be called something different in C++
I want to have a simple event system, somthing like
I use libsigc++. It's native for gtkmm.
A simple example losely adapted from the tutorial:
#include
#include
using namespace std;
class AlienDetector {
public:
void run ();
sigc::signal signal_detected;
};
void warn_people () {
cout << "There are aliens in the carpark!" << endl;
}
void AlienDetector::run () {
signal_detected.emit ();
}
int main () {
AlienDetector mydetector;
mydetector.signal_detected.connect (sigc::ptr_fun (warn_people));
mydetector.run ();
}
It also provides a mechanism to connect member-functions of specific objects to signals using sigc::mem_fun instead of sigc::ptr_fun:
sigc::mem_fun (someobject, &SomeClass::some_method);
This pretty much provides anything that is possible with GLib-signals.