]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengines/socketengine_poll.h
Make OnAcceptReady pure virtual, rename ListenSocket to ListenSocketBase, create...
[user/henk/code/inspircd.git] / include / socketengines / socketengine_poll.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __SOCKETENGINE_POLL__
15 #define __SOCKETENGINE_POLL__
16
17 #include <vector>
18 #include <string>
19 #include <map>
20 #include "inspircd_config.h"
21 #include "inspircd.h"
22 #include "socketengine.h"
23 #ifndef __USE_XOPEN
24         #define __USE_XOPEN /* fuck every fucking OS ever made. needed by poll.h to work.*/
25 #endif
26 #include <poll.h>
27 #include <sys/poll.h>
28
29 class InspIRCd;
30
31 /** A specialisation of the SocketEngine class, designed to use poll().
32  */
33 class PollEngine : public SocketEngine
34 {
35 private:
36         /** These are used by poll() to hold socket events
37          */
38         struct pollfd *events;
39 public:
40         /** Create a new PollEngine
41          * @param Instance The creator of this object
42          */
43         PollEngine(InspIRCd* Instance);
44         /** Delete a PollEngine
45          */
46         virtual ~PollEngine();
47         virtual bool AddFd(EventHandler* eh);
48         virtual int GetMaxFds();
49         virtual int GetRemainingFds();
50         virtual bool DelFd(EventHandler* eh, bool force = false);
51         virtual int DispatchEvents();
52         virtual std::string GetName();
53         virtual void WantWrite(EventHandler* eh);
54 };
55
56 /** Creates a SocketEngine
57  */
58 class SocketEngineFactory
59 {
60 public:
61         /** Create a new instance of SocketEngine based on PollEngine
62          */
63         SocketEngine* Create(InspIRCd* Instance) { return new PollEngine(Instance); }
64 };
65
66 #endif