#include <multiplexer.h>
Inheritance diagram for listener::MultiplexerListener:
Public Member Functions | |
MultiplexerListener (unsigned int priority=0) | |
MultiplexerListener (Publisher *p, unsigned int priority=0) | |
template<typename E> | |
void | connect (const basic::function1< void, E * > &f) |
The main method to connect an basic::function1<void, E*> to the multiplexer. Using this method, it is possible to connect several isg::function1 to this Listener. | |
virtual void | dump_listener (std::ostream &, int spaces=0) |
Dump informations about this MultiplexerListener. | |
Static Public Member Functions | |
template<typename E> | |
Listener::ID | connect (Publisher *p, Subscriber *s, const basic::function1< void, E * > &f, unsigned int priority=0) |
The main static method to do a connection. This method will create an appropriate Listener for f and add it to the Subscriber s. | |
template<typename E1, typename E2> | |
Listener::ID | connect (Publisher *p, Subscriber *s, const basic::function1< void, E1 * > &f1, const basic::function1< void, E2 * > &f2, unsigned int priority=0) |
template<typename E1, typename E2, typename E3> | |
Listener::ID | connect (Publisher *p, Subscriber *s, const basic::function1< void, E1 * > &f1, const basic::function1< void, E2 * > &f2, const basic::function1< void, E3 * > &f3, unsigned int priority=0) |
template<typename E> | |
bool | disconnect (Publisher *p, Subscriber *s, const basic::function1< void, E * > &f) |
The main static method to do a disconnection. | |
template<typename E> | |
Listener * | get_listener (Publisher *p, Subscriber *s, const basic::function1< void, E * > &f) |
The main static method to retrieve a Listener. | |
Protected Member Functions | |
bool | process_event (Event *e) |
This method is called when receiving an event and that the filters return true after processing. |
class NullEvent: public Event { } ; class MsgEvent: public Event { public: MsgEvent(const std::string& msg): msg_(msg) {} const std::string& message() const {return msg_ ;} private: std::string msg_ ; } ; class Receiver: public Subscriber { public: void msg_event(MsgEvent* e) { std::cerr << "Receives message \"" << e->message() << "\" from " << e->get_source() << std::endl ; } void null_event(NullEvent* e) { std::cerr << "Receives null event from " << e->get_source() << std::endl ; } } ; int main() { Publisher* p = new Publisher ; Receiver * r = new Receiver ; igs_connect(p, r, igs_functor(r, Receiver::null_event)) ; // or IGS_CONNECT(p, r, Receiver::null_event) ; igs_connect(p, r, igs_functor(r, Receiver::msg_event)) ; // or IGS_CONNECT(p, r, Receiver::msg_event) ; p->igs_emit(NullEvent) ; p->igs_emit(MsgEvent("Hello World")) ; }
Author :
Copyright (C) 2004, Igeoss - All Rights Reserved.
|
The main method to connect an basic::function1<void, E*> to the multiplexer. Using this method, it is possible to connect several isg::function1 to this Listener.
MultiplexerListener* m = new MultiplexerListener(p) ;
m->connect(igs_functor(s1, S::event1) ;
m->connect(igs_functor(s1, S::event2) ;
m->connect(igs_functor(s2, S::event1) ;
m->connect(igs_function(event1) ;
s->add_listener(m) ;
|
|
This method is called when receiving an event and that the filters return true after processing.
If any of the installed filters failed or if this Listener is blocked, this method is not called. Implements listener::Listener. |