]> git.tdb.fi Git - libs/core.git/blob - source/io/eventobject.h
Remove deprecated things
[libs/core.git] / source / io / eventobject.h
1 #ifndef MSP_IO_EVENTOBJECT_H_
2 #define MSP_IO_EVENTOBJECT_H_
3
4 #include "base.h"
5
6 namespace Msp {
7 namespace IO {
8
9 class Handle;
10
11 /**
12 Interface class for objects that can provide event-based I/O.  These objects
13 can be fed to the various poll functions in poll.h, or added to an
14 EventDispatcher to generate event signals.
15 */
16 class EventObject: public Base
17 {
18 public:
19         /** Emitted when there is data available for reading.  If all data is not
20         read, the signal is emitted again immediately. */
21         sigc::signal<void> signal_data_available;
22
23         /** Emitted when the mask of interesting events changes.  Mainly for use by
24         EventDispatcher. */
25         sigc::signal<void, PollEvent> signal_events_changed;
26
27 private:
28         PollEvent events;
29
30 protected:
31         EventObject();
32         virtual ~EventObject();
33
34         void set_events(PollEvent);
35 public:
36         /** Returns a mask of the currently interesting events.  Used by
37         EventDispatcher. */
38         PollEvent get_events() const { return events; }
39
40         /** Returns a handle for polling. */
41         virtual const Handle &get_event_handle() = 0;
42
43         /** Notifies the object of an event.  Used by EventDispatcher. */
44         void event(PollEvent);
45
46 protected:
47         /** Called when an event occurs.  Derived classes can implement this to
48         process events. */
49         virtual void on_event(PollEvent) { }
50 };
51
52 } // namespace IO
53 } // namespace Msp
54
55 #endif