]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ipcbase.h
changed wxFDIODispatcher::UnregisterFD() to take only fd, without flags, and unregist...
[wxWidgets.git] / include / wx / ipcbase.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: ipcbase.h
3// Purpose: Base classes for IPC
4// Author: Julian Smart
5// Modified by:
6// Created: 4/1/98
7// RCS-ID: $Id$
371a5b4e 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_IPCBASEH__
13#define _WX_IPCBASEH__
c801d85f
KB
14
15#include "wx/defs.h"
16#include "wx/object.h"
17#include "wx/string.h"
18
0d2a2b60
RR
19enum wxIPCFormat
20{
21 wxIPC_INVALID = 0,
22 wxIPC_TEXT = 1, /* CF_TEXT */
23 wxIPC_BITMAP = 2, /* CF_BITMAP */
24 wxIPC_METAFILE = 3, /* CF_METAFILEPICT */
25 wxIPC_SYLK = 4,
26 wxIPC_DIF = 5,
27 wxIPC_TIFF = 6,
28 wxIPC_OEMTEXT = 7, /* CF_OEMTEXT */
29 wxIPC_DIB = 8, /* CF_DIB */
30 wxIPC_PALETTE = 9,
31 wxIPC_PENDATA = 10,
32 wxIPC_RIFF = 11,
33 wxIPC_WAVE = 12,
34 wxIPC_UNICODETEXT = 13,
35 wxIPC_ENHMETAFILE = 14,
36 wxIPC_FILENAME = 15, /* CF_HDROP */
37 wxIPC_LOCALE = 16,
38 wxIPC_PRIVATE = 20
39};
40
b5dbe15d
VS
41class WXDLLIMPEXP_FWD_BASE wxServerBase;
42class WXDLLIMPEXP_FWD_BASE wxClientBase;
c801d85f 43
bddd7a8d 44class WXDLLIMPEXP_BASE wxConnectionBase: public wxObject
c801d85f
KB
45{
46 DECLARE_CLASS(wxConnectionBase)
f6bcfd97
BP
47
48public:
f010ad48
JS
49 wxConnectionBase(wxChar *buffer, int size); // use external buffer
50 wxConnectionBase(); // use internal, adaptive buffer
fbfb8bcc 51 wxConnectionBase(const wxConnectionBase& copy);
d3c7fc99 52 virtual ~wxConnectionBase(void);
f010ad48
JS
53
54 void SetConnected( bool c ) { m_connected = c; }
55 bool GetConnected() { return m_connected; }
c801d85f
KB
56
57 // Calls that CLIENT can make
e90c1d2a 58 virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0;
86501081
VS
59 // FIXME-UTF8: review this code for compatibility implications, update
60 // accordingly, don' use c_str() below
61 virtual bool Execute(const wxString& str)
62 { return Execute(str.c_str(), -1, wxIPC_TEXT); }
d38e8d5f 63 virtual wxChar *Request(const wxString& item, int *size = (int *) NULL, wxIPCFormat format = wxIPC_TEXT) = 0;
9d2f3c71 64 virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
c801d85f
KB
65 virtual bool StartAdvise(const wxString& item) = 0;
66 virtual bool StopAdvise(const wxString& item) = 0;
67
68 // Calls that SERVER can make
9d2f3c71 69 virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
c801d85f
KB
70
71 // Calls that both can make
72 virtual bool Disconnect(void) = 0;
73
74 // Callbacks to SERVER - override at will
85ac091e 75 virtual bool OnExecute ( const wxString& WXUNUSED(topic),
d38e8d5f 76 wxChar *WXUNUSED(data),
85ac091e
GRG
77 int WXUNUSED(size),
78 wxIPCFormat WXUNUSED(format) )
47b378bd 79 { return false; }
85ac091e 80
d38e8d5f 81 virtual wxChar *OnRequest ( const wxString& WXUNUSED(topic),
85ac091e
GRG
82 const wxString& WXUNUSED(item),
83 int *WXUNUSED(size),
84 wxIPCFormat WXUNUSED(format) )
47b378bd 85 { return (wxChar *) NULL; }
85ac091e
GRG
86
87 virtual bool OnPoke ( const wxString& WXUNUSED(topic),
88 const wxString& WXUNUSED(item),
89 wxChar *WXUNUSED(data),
90 int WXUNUSED(size),
91 wxIPCFormat WXUNUSED(format) )
47b378bd 92 { return false; }
85ac091e
GRG
93
94 virtual bool OnStartAdvise ( const wxString& WXUNUSED(topic),
95 const wxString& WXUNUSED(item) )
47b378bd 96 { return false; }
85ac091e
GRG
97
98 virtual bool OnStopAdvise ( const wxString& WXUNUSED(topic),
99 const wxString& WXUNUSED(item) )
47b378bd 100 { return false; }
c801d85f
KB
101
102 // Callbacks to CLIENT - override at will
85ac091e
GRG
103 virtual bool OnAdvise ( const wxString& WXUNUSED(topic),
104 const wxString& WXUNUSED(item),
d38e8d5f 105 wxChar *WXUNUSED(data),
85ac091e
GRG
106 int WXUNUSED(size),
107 wxIPCFormat WXUNUSED(format) )
47b378bd 108 { return false; }
c801d85f 109
f6bcfd97 110 // Callbacks to BOTH - override at will
7beb59f3 111 // Default behaviour is to delete connection and return true
c801d85f 112 virtual bool OnDisconnect(void) = 0;
f010ad48
JS
113
114 // return a buffer at least this size, reallocating buffer if needed
115 // returns NULL if using an inadequate user buffer - it can't be resized
116 wxChar * GetBufferAtLeast( size_t bytes );
117
118protected:
119 bool m_connected;
120private:
121 wxChar * m_buffer;
122 size_t m_buffersize;
123 bool m_deletebufferwhendone;
22f3361e 124
00e7a427
VZ
125 // can't use DECLARE_NO_COPY_CLASS(wxConnectionBase) because we already
126 // have copy ctor but still forbid the default assignment operator
127 wxConnectionBase& operator=(const wxConnectionBase&);
c801d85f
KB
128};
129
f010ad48 130
bddd7a8d 131class WXDLLIMPEXP_BASE wxServerBase: public wxObject
c801d85f
KB
132{
133 DECLARE_CLASS(wxServerBase)
c801d85f 134
f6bcfd97 135public:
c801d85f 136 inline wxServerBase(void) {}
6fb99eb3 137 inline ~wxServerBase(void) {}
c801d85f 138
7beb59f3 139 // Returns false on error (e.g. port number is already in use)
f6bcfd97
BP
140 virtual bool Create(const wxString& serverName) = 0;
141
142 // Callbacks to SERVER - override at will
143 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic) = 0;
c801d85f
KB
144};
145
bddd7a8d 146class WXDLLIMPEXP_BASE wxClientBase: public wxObject
c801d85f
KB
147{
148 DECLARE_CLASS(wxClientBase)
f6bcfd97
BP
149
150public:
6fb99eb3
WS
151 inline wxClientBase(void) {}
152 inline ~wxClientBase(void) {}
f6bcfd97 153
c801d85f 154 virtual bool ValidHost(const wxString& host) = 0;
c801d85f 155
f6bcfd97
BP
156 // Call this to make a connection. Returns NULL if cannot.
157 virtual wxConnectionBase *MakeConnection(const wxString& host,
158 const wxString& server,
159 const wxString& topic) = 0;
160
161 // Callbacks to CLIENT - override at will
162 virtual wxConnectionBase *OnMakeConnection(void) = 0;
c801d85f
KB
163};
164
165#endif
34138703 166 // _WX_IPCBASEH__