]>
Commit | Line | Data |
---|---|---|
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 | #ifdef __VMS | |
20 | #include <sys/socket.h> | |
21 | #endif | |
22 | ||
23 | #include "wx/hash.h" | |
24 | ||
25 | // forward declarations | |
26 | class wxSocketEventDispatcherEntry; | |
27 | class GSocket; | |
28 | ||
29 | enum wxSocketEventDispatcherType | |
30 | { | |
31 | wxSocketEventDispatcherInput, | |
32 | wxSocketEventDispatcherOutput | |
33 | }; | |
34 | ||
35 | class WXDLLIMPEXP_CORE wxSocketEventDispatcher : public wxHashTable | |
36 | { | |
37 | protected: | |
38 | wxSocketEventDispatcher() : wxHashTable(wxKEY_INTEGER) {} | |
39 | ||
40 | public: | |
41 | // returns instance of the table | |
42 | static wxSocketEventDispatcher& Get(); | |
43 | ||
44 | virtual ~wxSocketEventDispatcher() | |
45 | { | |
46 | WX_CLEAR_HASH_TABLE(*this) | |
47 | } | |
48 | ||
49 | void RegisterCallback(int fd, wxSocketEventDispatcherType socketType, | |
50 | GSocket* socket); | |
51 | ||
52 | void UnregisterCallback(int fd, wxSocketEventDispatcherType socketType); | |
53 | ||
54 | void RunLoop(int timeout = 0); | |
55 | ||
56 | private: | |
57 | void AddEvents(fd_set* readset, fd_set* writeset); | |
58 | ||
59 | int FillSets(fd_set* readset, fd_set* writeset); | |
60 | ||
61 | wxSocketEventDispatcherEntry* FindEntry(int fd); | |
62 | ||
63 | private: | |
64 | static wxSocketEventDispatcher *ms_instance; | |
65 | ||
66 | friend class wxSocketEventDispatcherModule; | |
67 | }; | |
68 | ||
69 | #endif // wxUSE_SOCKETS | |
70 | ||
71 | #endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_ |