]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengine_select.h
Add m_hidechans: Adds usermode +I to hide an oper's channels from non-opers. Also...
[user/henk/code/inspircd.git] / include / socketengine_select.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15 */
16
17 #ifndef __SOCKETENGINE_SELECT__
18 #define __SOCKETENGINE_SELECT__
19
20 #include <vector>
21 #include <string>
22 #include <map>
23 #include <sys/select.h>
24 #include "inspircd_config.h"
25 #include "globals.h"
26 #include "inspircd.h"
27 #include "socketengine.h"
28
29 class InspIRCd;
30
31 /** A specialisation of the SocketEngine class, designed to use traditional select().
32  */
33 class SelectEngine : public SocketEngine
34 {
35 private:
36         /** Because select() does not track an fd list for us between calls, we have one of our own
37          */
38         std::map<int,int> fds;
39         /** The read set and write set, populated before each call to select().
40          */
41         fd_set wfdset, rfdset;
42 public:
43         /** Create a new SelectEngine
44          * @param Instance The creator of this object
45          */
46         SelectEngine(InspIRCd* Instance);
47         /** Delete a SelectEngine
48          */
49         virtual ~SelectEngine();
50         virtual bool AddFd(EventHandler* eh);
51         virtual int GetMaxFds();
52         virtual int GetRemainingFds();
53         virtual bool DelFd(EventHandler* eh);
54         virtual int DispatchEvents();
55         virtual std::string GetName();
56 };
57
58 /** Creates a SocketEngine
59  */
60 class SocketEngineFactory
61 {
62 public:
63         /** Create a new instance of SocketEngine based on SelectEngine
64          */
65         SocketEngine* Create(InspIRCd* Instance) { return new SelectEngine(Instance); }
66 };
67
68 #endif