]>
Commit | Line | Data |
---|---|---|
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$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_IPCBASEH__ | |
13 | #define _WX_IPCBASEH__ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "ipcbase.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | #include "wx/object.h" | |
21 | #include "wx/string.h" | |
22 | ||
23 | enum wxIPCFormat | |
24 | { | |
25 | wxIPC_INVALID = 0, | |
26 | wxIPC_TEXT = 1, /* CF_TEXT */ | |
27 | wxIPC_BITMAP = 2, /* CF_BITMAP */ | |
28 | wxIPC_METAFILE = 3, /* CF_METAFILEPICT */ | |
29 | wxIPC_SYLK = 4, | |
30 | wxIPC_DIF = 5, | |
31 | wxIPC_TIFF = 6, | |
32 | wxIPC_OEMTEXT = 7, /* CF_OEMTEXT */ | |
33 | wxIPC_DIB = 8, /* CF_DIB */ | |
34 | wxIPC_PALETTE = 9, | |
35 | wxIPC_PENDATA = 10, | |
36 | wxIPC_RIFF = 11, | |
37 | wxIPC_WAVE = 12, | |
38 | wxIPC_UNICODETEXT = 13, | |
39 | wxIPC_ENHMETAFILE = 14, | |
40 | wxIPC_FILENAME = 15, /* CF_HDROP */ | |
41 | wxIPC_LOCALE = 16, | |
42 | wxIPC_PRIVATE = 20 | |
43 | }; | |
44 | ||
45 | class WXDLLEXPORT wxServerBase; | |
46 | class WXDLLEXPORT wxClientBase; | |
47 | ||
48 | class WXDLLEXPORT wxConnectionBase: public wxObject | |
49 | { | |
50 | DECLARE_CLASS(wxConnectionBase) | |
51 | public: | |
52 | inline wxConnectionBase(void) {} | |
53 | inline ~wxConnectionBase(void) {} | |
54 | ||
55 | // Calls that CLIENT can make | |
56 | virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0; | |
57 | virtual bool Execute(const wxString& str) { return Execute(str, -1, wxIPC_TEXT); } | |
58 | virtual char *Request(const wxString& item, int *size = (int *) NULL, wxIPCFormat format = wxIPC_TEXT) = 0; | |
59 | virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0; | |
60 | virtual bool StartAdvise(const wxString& item) = 0; | |
61 | virtual bool StopAdvise(const wxString& item) = 0; | |
62 | ||
63 | // Calls that SERVER can make | |
64 | virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0; | |
65 | ||
66 | // Calls that both can make | |
67 | virtual bool Disconnect(void) = 0; | |
68 | ||
69 | // Callbacks to SERVER - override at will | |
70 | virtual bool OnExecute ( const wxString& WXUNUSED(topic), | |
71 | char *WXUNUSED(data), | |
72 | int WXUNUSED(size), | |
73 | wxIPCFormat WXUNUSED(format) ) | |
74 | { return FALSE; }; | |
75 | ||
76 | virtual char *OnRequest ( const wxString& WXUNUSED(topic), | |
77 | const wxString& WXUNUSED(item), | |
78 | int *WXUNUSED(size), | |
79 | wxIPCFormat WXUNUSED(format) ) | |
80 | { return (char *) NULL; }; | |
81 | ||
82 | virtual bool OnPoke ( const wxString& WXUNUSED(topic), | |
83 | const wxString& WXUNUSED(item), | |
84 | wxChar *WXUNUSED(data), | |
85 | int WXUNUSED(size), | |
86 | wxIPCFormat WXUNUSED(format) ) | |
87 | { return FALSE; }; | |
88 | ||
89 | virtual bool OnStartAdvise ( const wxString& WXUNUSED(topic), | |
90 | const wxString& WXUNUSED(item) ) | |
91 | { return FALSE; }; | |
92 | ||
93 | virtual bool OnStopAdvise ( const wxString& WXUNUSED(topic), | |
94 | const wxString& WXUNUSED(item) ) | |
95 | { return FALSE; }; | |
96 | ||
97 | // Callbacks to CLIENT - override at will | |
98 | virtual bool OnAdvise ( const wxString& WXUNUSED(topic), | |
99 | const wxString& WXUNUSED(item), | |
100 | char *WXUNUSED(data), | |
101 | int WXUNUSED(size), | |
102 | wxIPCFormat WXUNUSED(format) ) | |
103 | { return FALSE; }; | |
104 | ||
105 | // Callbacks to BOTH | |
106 | ||
107 | // Default behaviour is to delete connection and return TRUE | |
108 | virtual bool OnDisconnect(void) = 0; | |
109 | }; | |
110 | ||
111 | class WXDLLEXPORT wxServerBase: public wxObject | |
112 | { | |
113 | DECLARE_CLASS(wxServerBase) | |
114 | public: | |
115 | ||
116 | inline wxServerBase(void) {} | |
117 | inline ~wxServerBase(void) {}; | |
118 | virtual bool Create(const wxString& serverName) = 0; // Returns FALSE if can't create server (e.g. port | |
119 | // number is already in use) | |
120 | virtual wxConnectionBase *OnAcceptConnection(const wxString& topic) = 0; | |
121 | ||
122 | }; | |
123 | ||
124 | class WXDLLEXPORT wxClientBase: public wxObject | |
125 | { | |
126 | DECLARE_CLASS(wxClientBase) | |
127 | public: | |
128 | inline wxClientBase(void) {}; | |
129 | inline ~wxClientBase(void) {}; | |
130 | virtual bool ValidHost(const wxString& host) = 0; | |
131 | virtual wxConnectionBase *MakeConnection(const wxString& host, const wxString& server, const wxString& topic) = 0; | |
132 | // Call this to make a connection. | |
133 | // Returns NULL if cannot. | |
134 | virtual wxConnectionBase *OnMakeConnection(void) = 0; // Tailor this to return own connection. | |
135 | ||
136 | }; | |
137 | ||
138 | #endif | |
139 | // _WX_IPCBASEH__ |