]> git.saurik.com Git - wxWidgets.git/blame - include/wx/private/socketevtdispatch.h
include wx/object.h now that wxConfigBase derives from wxObject
[wxWidgets.git] / include / wx / private / socketevtdispatch.h
CommitLineData
6b44a335
VS
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
bb8bd6ef
JJ
19#ifdef __VMS
20#include <sys/socket.h>
21#endif
22
6b44a335
VS
23#include "wx/hash.h"
24
25// forward declarations
26class wxSocketEventDispatcherEntry;
27class GSocket;
28
29enum wxSocketEventDispatcherType
30{
31 wxSocketEventDispatcherInput,
32 wxSocketEventDispatcherOutput
33};
34
35class WXDLLIMPEXP_CORE wxSocketEventDispatcher : public wxHashTable
36{
37protected:
38 wxSocketEventDispatcher() : wxHashTable(wxKEY_INTEGER) {}
39
40public:
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
56private:
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
63private:
64 static wxSocketEventDispatcher *ms_instance;
65
66 friend class wxSocketEventDispatcherModule;
67};
68
69#endif // wxUSE_SOCKETS
70
71#endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_