]> git.saurik.com Git - wxWidgets.git/blame - include/wx/private/fdiodispatcher.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / private / fdiodispatcher.h
CommitLineData
b46b1d59
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/private/fdiodispatcher.h
3// Purpose: classes for dispatching IO notifications for file descriptors
4// Authors: Lukasz Michalski
5// Created: December 2006
6// Copyright: (c) Lukasz Michalski
b46b1d59
VZ
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_PRIVATE_FDIODISPATCHER_H_
11#define _WX_PRIVATE_FDIODISPATCHER_H_
12
13#include "wx/hashmap.h"
3327957c 14#include "wx/private/fdiohandler.h"
b46b1d59
VZ
15
16// those flags describes sets where descriptor should be added
17enum wxFDIODispatcherEntryFlags
18{
19 wxFDIO_INPUT = 1,
20 wxFDIO_OUTPUT = 2,
21 wxFDIO_EXCEPTION = 4,
22 wxFDIO_ALL = wxFDIO_INPUT | wxFDIO_OUTPUT | wxFDIO_EXCEPTION
23};
24
ad8d42f8
VZ
25// base class for wxSelectDispatcher and wxEpollDispatcher
26class WXDLLIMPEXP_BASE wxFDIODispatcher
27{
28public:
29 enum { TIMEOUT_INFINITE = -1 };
30
5e1eac14
VZ
31 // return the global dispatcher to be used for IO events, can be NULL only
32 // if wxSelectDispatcher wasn't compiled into the library at all as
33 // creating it never fails
34 //
35 // don't delete the returned pointer
36 static wxFDIODispatcher *Get();
37
38 // if we have any registered handlers, check for any pending events to them
39 // and dispatch them -- this is used from wxX11 and wxDFB event loops
40 // implementation
41 static void DispatchPending();
42
ad8d42f8
VZ
43 // register handler for the given descriptor with the dispatcher, return
44 // true on success or false on error
45 virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags) = 0;
46
47 // modify descriptor flags or handler, return true on success
48 virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags) = 0;
49
af57c51a
VZ
50 // unregister descriptor previously registered with RegisterFD()
51 virtual bool UnregisterFD(int fd) = 0;
ad8d42f8 52
a12698ab
VZ
53 // check if any events are currently available without dispatching them
54 virtual bool HasPending() const = 0;
55
5a557d1e 56 // wait for an event for at most timeout milliseconds and process it;
a12698ab
VZ
57 // return the number of events processed (possibly 0 if timeout expired) or
58 // -1 if an error occurred
59 virtual int Dispatch(int timeout = TIMEOUT_INFINITE) = 0;
ad8d42f8
VZ
60
61 virtual ~wxFDIODispatcher() { }
62};
63
64//entry for wxFDIOHandlerMap
b46b1d59
VZ
65struct wxFDIOHandlerEntry
66{
67 wxFDIOHandlerEntry()
68 {
69 }
70
71 wxFDIOHandlerEntry(wxFDIOHandler *handler_, int flags_)
72 : handler(handler_),
73 flags(flags_)
74 {
75 }
76
77 wxFDIOHandler *handler;
78 int flags;
79};
80
81// this hash is used to map file descriptors to their handlers
82WX_DECLARE_HASH_MAP(
83 int,
84 wxFDIOHandlerEntry,
85 wxIntegerHash,
86 wxIntegerEqual,
87 wxFDIOHandlerMap
88);
89
ad8d42f8
VZ
90// FDIODispatcher that holds map fd <-> FDIOHandler, this should be used if
91// this map isn't maintained elsewhere already as it is usually needed anyhow
b46b1d59 92//
ad8d42f8 93// notice that all functions for FD management have implementation
b46b1d59 94// in the base class and should be called from the derived classes
af57c51a
VZ
95class WXDLLIMPEXP_BASE wxMappedFDIODispatcher : public wxFDIODispatcher
96{
b46b1d59 97public:
b46b1d59
VZ
98 // find the handler for the given fd, return NULL if none
99 wxFDIOHandler *FindHandler(int fd) const;
af57c51a 100
b46b1d59
VZ
101 // register handler for the given descriptor with the dispatcher, return
102 // true on success or false on error
ad8d42f8 103 virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags);
b46b1d59
VZ
104
105 // modify descriptor flags or handler, return true on success
ad8d42f8 106 virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags);
b46b1d59 107
af57c51a
VZ
108 // unregister descriptor previously registered with RegisterFD()
109 virtual bool UnregisterFD(int fd);
b46b1d59 110
ad8d42f8 111 virtual ~wxMappedFDIODispatcher() { }
b46b1d59
VZ
112
113protected:
114 // the fd -> handler map containing all the registered handlers
115 wxFDIOHandlerMap m_handlers;
116};
117
118#endif // _WX_PRIVATE_FDIODISPATCHER_H_