template <typename E> Listener::ID igs_connect(Publisher* publisher, Subscriber* susbscriber, const basic::function1<void, E*>& f, unsigned int priority=0) ; template <typename E> bool igs_disconnect(Publisher* puslisher, Subscriber* subscriber, const basic::function1<void, E*>& f) ;and the related macros are:
igs_functor(SUBSCRIBER, METHOD) ; igs_function(FUNCTION) ;Example of use:
class Event1: public Event {} ; class Event2: public Event {} ; class Event3: public Event {} ; class S: public Subscriber { public: void event1(Event1*) {std::cerr << "1\n" ;} void event2(Event2*) {std::cerr << "2\n" ;} void event3(Event3*) {std::cerr << "3\n" ;} } ; int main() { Publisher p ; S s ; igs_connect(&p, &s, igs_functor(&s, S::event1)) ; igs_connect(&p, &s, igs_functor(&s, S::event2)) ; igs_connect(&p, &s, igs_functor(&s, S::event3)) ; p.igs_emit(Event1) ; p.igs_emit(Event2) ; p.igs_emit(Event3) ; igs_disconnect(&p, &s, igs_functor(&s, S::event3)) ; p.igs_emit(Event3) ; // never received }Here, we see that no special Listener for each Event is created, and that the MultiplexerListener class is used through the igs_connect function to listen to the special events defined by the S member functions. This class automatically recognize the Event type argument and do the necessary connections.
class S { public: void event1(Event1*) {} void event2(Event2*) {} } ; void event3(Event3*) {} int main() { Publisher* pub = new Publisher ; Subscriber sub ; S* s = new S ; igs_connect(pub, sub, igs_functor(s, S::event1)) ; igs_connect(pub, sub, igs_functor(s, S::event2)) ; igs_connect(pub, sub, igs_function(event3)) ; pub->igs_emit(Event3) ; ... }