1 #ifndef MSP_IO_EVENTDISPATCHER_H_
2 #define MSP_IO_EVENTDISPATCHER_H_
5 #include <sigc++/trackable.h>
6 #include <msp/core/mspcore_api.h>
7 #include <msp/time/timedelta.h>
8 #include <msp/time/timer.h>
15 Put your I/O objects inside one of these to get signaled when something happens
18 class MSPCORE_API EventDispatcher
21 struct Slot: public sigc::trackable
23 EventDispatcher &disp;
26 Slot(EventDispatcher &d, EventObject &o): disp(d), obj(o) { }
28 void connect_signals() const;
29 void events_changed(PollEvent) const;
32 bool operator<(const Slot &o) const { return &obj<&o.obj; }
36 std::set<Slot> objects;
39 void add(EventObject &);
40 void remove(EventObject &);
42 /** Checks for and dispatches events. If there are no events available,
43 blocks until there are. */
46 /** Checks for and dispatches events. If there are no events available,
47 waits at most the specified time before returning. */
48 void tick(const Time::TimeDelta &);
50 /** Checks for and dispatches events. If there are no events available,
51 waits until the timer's next timeout before returning. */
52 void tick(const Time::Timer &);