1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Base classes for IPC
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_IPCBASEH__
13 #define _WX_IPCBASEH__
16 #pragma interface "ipcbase.h"
20 #include "wx/object.h"
21 #include "wx/string.h"
26 wxIPC_TEXT
= 1, /* CF_TEXT */
27 wxIPC_BITMAP
= 2, /* CF_BITMAP */
28 wxIPC_METAFILE
= 3, /* CF_METAFILEPICT */
32 wxIPC_OEMTEXT
= 7, /* CF_OEMTEXT */
33 wxIPC_DIB
= 8, /* CF_DIB */
38 wxIPC_UNICODETEXT
= 13,
39 wxIPC_ENHMETAFILE
= 14,
40 wxIPC_FILENAME
= 15, /* CF_HDROP */
45 class WXDLLEXPORT wxServerBase
;
46 class WXDLLEXPORT wxClientBase
;
48 class WXDLLEXPORT wxConnectionBase
: public wxObject
50 DECLARE_CLASS(wxConnectionBase
)
52 inline wxConnectionBase(void) {}
53 inline ~wxConnectionBase(void) {}
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;
63 // Calls that SERVER can make
64 virtual bool Advise(const wxString
& item
, wxChar
*data
, int size
= -1, wxIPCFormat format
= wxIPC_TEXT
) = 0;
66 // Calls that both can make
67 virtual bool Disconnect(void) = 0;
69 // Callbacks to SERVER - override at will
70 virtual bool OnExecute ( const wxString
& WXUNUSED(topic
),
73 wxIPCFormat
WXUNUSED(format
) )
76 virtual char *OnRequest ( const wxString
& WXUNUSED(topic
),
77 const wxString
& WXUNUSED(item
),
79 wxIPCFormat
WXUNUSED(format
) )
80 { return (char *) NULL
; };
82 virtual bool OnPoke ( const wxString
& WXUNUSED(topic
),
83 const wxString
& WXUNUSED(item
),
84 wxChar
*WXUNUSED(data
),
86 wxIPCFormat
WXUNUSED(format
) )
89 virtual bool OnStartAdvise ( const wxString
& WXUNUSED(topic
),
90 const wxString
& WXUNUSED(item
) )
93 virtual bool OnStopAdvise ( const wxString
& WXUNUSED(topic
),
94 const wxString
& WXUNUSED(item
) )
97 // Callbacks to CLIENT - override at will
98 virtual bool OnAdvise ( const wxString
& WXUNUSED(topic
),
99 const wxString
& WXUNUSED(item
),
100 char *WXUNUSED(data
),
102 wxIPCFormat
WXUNUSED(format
) )
107 // Default behaviour is to delete connection and return TRUE
108 virtual bool OnDisconnect(void) = 0;
111 class WXDLLEXPORT wxServerBase
: public wxObject
113 DECLARE_CLASS(wxServerBase
)
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;
124 class WXDLLEXPORT wxClientBase
: public wxObject
126 DECLARE_CLASS(wxClientBase
)
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.