1 #ifndef MSP_IO_EVENTDISPATCHER_H_
2 #define MSP_IO_EVENTDISPATCHER_H_
5 #include <sigc++/trackable.h>
6 #include <msp/time/timedelta.h>
7 #include <msp/time/timer.h>
14 Put your I/O objects inside one of these to get signaled when something happens
20 struct Slot: public sigc::trackable
22 EventDispatcher &disp;
25 Slot(EventDispatcher &d, EventObject &o): disp(d), obj(o) { }
27 void connect_signals() const;
28 void events_changed(PollEvent) const;
31 bool operator<(const Slot &o) const { return &obj<&o.obj; }
35 std::set<Slot> objects;
38 void add(EventObject &);
39 void remove(EventObject &);
41 /** Checks for and dispatches events. If there are no events available,
42 blocks until there are. */
45 /** Checks for and dispatches events. If there are no events available,
46 waits at most the specified time before returning. */
47 void tick(const Time::TimeDelta &);
49 /** Checks for and dispatches events. If there are no events available,
50 waits until the timer's next timeout before returning. */
51 void tick(const Time::Timer &);