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"
23 class WXDLLEXPORT wxDDEServerBase
;
24 class WXDLLEXPORT wxDDEClientBase
;
26 class WXDLLEXPORT wxConnectionBase
: public wxObject
28 DECLARE_CLASS(wxConnectionBase
)
30 inline wxConnectionBase(void) {}
31 inline ~wxConnectionBase(void) {}
33 // Calls that CLIENT can make
34 virtual bool Execute(char *data
, int size
= -1, wxDataFormat format
= wxDF_TEXT
) = 0;
35 virtual bool Execute(const wxString
& str
) { return Execute((char *)(const char *)str
, -1, wxDF_TEXT
); }
36 virtual char *Request(const wxString
& item
, int *size
= NULL
, wxDataFormat format
= wxDF_TEXT
) = 0;
37 virtual bool Poke(const wxString
& item
, char *data
, int size
= -1, wxDataFormat format
= wxDF_TEXT
) = 0;
38 virtual bool StartAdvise(const wxString
& item
) = 0;
39 virtual bool StopAdvise(const wxString
& item
) = 0;
41 // Calls that SERVER can make
42 virtual bool Advise(const wxString
& item
, char *data
, int size
= -1, wxDataFormat format
= wxDF_TEXT
) = 0;
44 // Calls that both can make
45 virtual bool Disconnect(void) = 0;
47 // Callbacks to SERVER - override at will
48 virtual bool OnExecute( const wxString
& WXUNUSED(topic
), char *WXUNUSED(data
), int WXUNUSED(size
),
49 int WXUNUSED(format
) ) { return FALSE
; };
50 virtual char *OnRequest( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
),
51 int *WXUNUSED(size
), int WXUNUSED(format
) ) { return NULL
; };
52 virtual bool OnPoke( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
), char *WXUNUSED(data
),
53 int WXUNUSED(size
), int WXUNUSED(format
) ) { return FALSE
; };
54 virtual bool OnStartAdvise( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
) )
56 virtual bool OnStopAdvise( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
) )
59 // Callbacks to CLIENT - override at will
60 virtual bool OnAdvise( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
), char *WXUNUSED(data
),
61 int WXUNUSED(size
), int WXUNUSED(format
) ) { return FALSE
; };
65 // Default behaviour is to delete connection and return TRUE
66 virtual bool OnDisconnect(void) = 0;
69 class WXDLLEXPORT wxServerBase
: public wxObject
71 DECLARE_CLASS(wxServerBase
)
74 inline wxServerBase(void) {}
75 inline ~wxServerBase(void) {};
76 virtual bool Create(const wxString
& serverName
) = 0; // Returns FALSE if can't create server (e.g. port
77 // number is already in use)
78 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
) = 0;
82 class WXDLLEXPORT wxClientBase
: public wxObject
84 DECLARE_CLASS(wxClientBase
)
86 inline wxClientBase(void) {};
87 inline ~wxClientBase(void) {};
88 virtual bool ValidHost(const wxString
& host
) = 0;
89 virtual wxConnectionBase
*MakeConnection(const wxString
& host
, const wxString
& server
, const wxString
& topic
) = 0;
90 // Call this to make a connection.
91 // Returns NULL if cannot.
92 virtual wxConnectionBase
*OnMakeConnection(void) = 0; // Tailor this to return own connection.