1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Base classes for IPC
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
16 #include "wx/object.h"
17 #include "wx/string.h"
19 class WXDLLEXPORT wxDDEServerBase
;
20 class WXDLLEXPORT wxDDEClientBase
;
22 class WXDLLEXPORT wxConnectionBase
: public wxObject
24 DECLARE_CLASS(wxConnectionBase
)
26 inline wxConnectionBase(void) {}
27 inline ~wxConnectionBase(void) {}
29 // Calls that CLIENT can make
30 virtual bool Execute(char *data
, int size
= -1, int format
= wxCF_TEXT
) = 0;
31 virtual bool Execute(const wxString
& str
) { return Execute((char *)(const char *)str
, -1, wxCF_TEXT
); }
32 virtual char *Request(const wxString
& item
, int *size
= NULL
, int format
= wxCF_TEXT
) = 0;
33 virtual bool Poke(const wxString
& item
, char *data
, int size
= -1, int format
= wxCF_TEXT
) = 0;
34 virtual bool StartAdvise(const wxString
& item
) = 0;
35 virtual bool StopAdvise(const wxString
& item
) = 0;
37 // Calls that SERVER can make
38 virtual bool Advise(const wxString
& item
, char *data
, int size
= -1, int format
= wxCF_TEXT
) = 0;
40 // Calls that both can make
41 virtual bool Disconnect(void) = 0;
43 // Callbacks to SERVER - override at will
44 virtual bool OnExecute( const wxString
& WXUNUSED(topic
), char *WXUNUSED(data
), int WXUNUSED(size
),
45 int WXUNUSED(format
) ) { return FALSE
; };
46 virtual char *OnRequest( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
),
47 int *WXUNUSED(size
), int WXUNUSED(format
) ) { return NULL
; };
48 virtual bool OnPoke( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
), char *WXUNUSED(data
),
49 int WXUNUSED(size
), int WXUNUSED(format
) ) { return FALSE
; };
50 virtual bool OnStartAdvise( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
) )
52 virtual bool OnStopAdvise( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
) )
55 // Callbacks to CLIENT - override at will
56 virtual bool OnAdvise( const wxString
& WXUNUSED(topic
), const wxString
& WXUNUSED(item
), char *WXUNUSED(data
),
57 int WXUNUSED(size
), int WXUNUSED(format
) ) { return FALSE
; };
61 // Default behaviour is to delete connection and return TRUE
62 virtual bool OnDisconnect(void) = 0;
65 class WXDLLEXPORT wxServerBase
: public wxObject
67 DECLARE_CLASS(wxServerBase
)
70 inline wxServerBase(void) {}
71 inline ~wxServerBase(void) {};
72 virtual bool Create(const wxString
& serverName
) = 0; // Returns FALSE if can't create server (e.g. port
73 // number is already in use)
74 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
) = 0;
78 class WXDLLEXPORT wxClientBase
: public wxObject
80 DECLARE_CLASS(wxClientBase
)
82 inline wxClientBase(void) {};
83 inline ~wxClientBase(void) {};
84 virtual bool ValidHost(const wxString
& host
) = 0;
85 virtual wxConnectionBase
*MakeConnection(const wxString
& host
, const wxString
& server
, const wxString
& topic
) = 0;
86 // Call this to make a connection.
87 // Returns NULL if cannot.
88 virtual wxConnectionBase
*OnMakeConnection(void) = 0; // Tailor this to return own connection.