]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengines/socketengine_poll.h
This include doesn't exist in 1.2
[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
28 class InspIRCd;
29
30 /** A specialisation of the SocketEngine class, designed to use poll().
31  */
32 class PollEngine : public SocketEngine
33 {
34 private:
35         /** These are used by poll() to hold socket events
36          */
37         struct pollfd *events;
38 public:
39         /** Create a new PollEngine
40          * @param Instance The creator of this object
41          */
42         PollEngine(InspIRCd* Instance);
43         /** Delete a PollEngine
44          */
45         virtual ~PollEngine();
46         virtual bool AddFd(EventHandler* eh);
47         virtual int GetMaxFds();
48         virtual int GetRemainingFds();
49         virtual bool DelFd(EventHandler* eh, bool force = false);
50         virtual int DispatchEvents();
51         virtual std::string GetName();
52         virtual void WantWrite(EventHandler* eh);
53 };
54
55 /** Creates a SocketEngine
56  */
57 class SocketEngineFactory
58 {
59 public:
60         /** Create a new instance of SocketEngine based on PollEngine
61          */
62         SocketEngine* Create(InspIRCd* Instance) { return new PollEngine(Instance); }
63 };
64
65 #endif