1 /**
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * io/pollable.h
8  * (c) 2007 Murat Deligonul
9  */
10 
11 #ifndef __IO_POLLABLE_H
12 #define __IO_POLLABLE_H
13 
14 #include "io/event.h"
15 
16 namespace io {
17 
18 class pollable {
19 private:
20 	int fd;
21 	short events;
22 
23 	friend class engine;
24 
25 protected:
set_fd(int f)26 	void set_fd(int f) {
27 		fd = f;
28 	}
set_events(short events)29 	void set_events(short events) {
30 		this->events = events;
31 	}
32 
33 public:
get_fd()34 	int get_fd() const {
35 		return fd;
36 	}
get_events()37 	short get_events() const {
38 		return events;
39 	}
40 
41 public:
pollable()42 	pollable() : fd(-1), events(EVENT_NONE) { }
43 	explicit pollable(int f, short e = EVENT_NONE) :
fd(f)44 			fd(f), events(e) { }
~pollable()45 	virtual ~pollable() {}
46 	virtual int event_callback(int) = 0;
47 };
48 
49 } /* namespace net */
50 #endif  /* __IO_POLLABLE_H */
51