]> git.saurik.com Git - wxWidgets.git/blob - include/wx/private/socketevtdispatch.h
added wxTreeCtrl::CollapseAll[Children]() and IsEmpty() to version-script and use...
[wxWidgets.git] / include / wx / private / socketevtdispatch.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/private/socketevtdispatch.h
3 // Purpose: wxSocketEventDispatcher class
4 // Authors: Angel Vidal
5 // Modified by:
6 // Created: August 2006
7 // Copyright: (c) Angel Vidal
8 // RCS-ID: $Id$
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PRIVATE_SOCKETEVTDISPATCH_H_
13 #define _WX_PRIVATE_SOCKETEVTDISPATCH_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_SOCKETS
18
19 #include "wx/hash.h"
20
21 // forward declarations
22 class wxSocketEventDispatcherEntry;
23 class GSocket;
24
25 enum wxSocketEventDispatcherType
26 {
27 wxSocketEventDispatcherInput,
28 wxSocketEventDispatcherOutput
29 };
30
31 class WXDLLIMPEXP_CORE wxSocketEventDispatcher : public wxHashTable
32 {
33 protected:
34 wxSocketEventDispatcher() : wxHashTable(wxKEY_INTEGER) {}
35
36 public:
37 // returns instance of the table
38 static wxSocketEventDispatcher& Get();
39
40 virtual ~wxSocketEventDispatcher()
41 {
42 WX_CLEAR_HASH_TABLE(*this)
43 }
44
45 void RegisterCallback(int fd, wxSocketEventDispatcherType socketType,
46 GSocket* socket);
47
48 void UnregisterCallback(int fd, wxSocketEventDispatcherType socketType);
49
50 void RunLoop(int timeout = 0);
51
52 private:
53 void AddEvents(fd_set* readset, fd_set* writeset);
54
55 int FillSets(fd_set* readset, fd_set* writeset);
56
57 wxSocketEventDispatcherEntry* FindEntry(int fd);
58
59 private:
60 static wxSocketEventDispatcher *ms_instance;
61
62 friend class wxSocketEventDispatcherModule;
63 };
64
65 #endif // wxUSE_SOCKETS
66
67 #endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_