]>
Commit | Line | Data |
---|---|---|
cf447356 GL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: process.h | |
3 | // Purpose: wxProcess class | |
4 | // Author: Guilhem Lavaux | |
7e84f02d | 5 | // Modified by: Vadim Zeitlin to check error codes, added Detach() method |
cf447356 GL |
6 | // Created: 24/06/98 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Guilhem Lavaux | |
7e84f02d | 9 | // Licence: wxWindows license |
cf447356 GL |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_PROCESSH__ |
13 | #define _WX_PROCESSH__ | |
cf447356 GL |
14 | |
15 | #ifdef __GNUG__ | |
5336ece4 | 16 | #pragma interface "process.h" |
cf447356 GL |
17 | #endif |
18 | ||
19 | #include "wx/defs.h" | |
20 | #include "wx/object.h" | |
21 | #include "wx/event.h" | |
8b33ae2d | 22 | #include "wx/stream.h" |
cf447356 | 23 | |
5336ece4 VZ |
24 | // Process Event handling |
25 | class WXDLLEXPORT wxProcessEvent : public wxEvent | |
cf447356 | 26 | { |
5336ece4 | 27 | DECLARE_DYNAMIC_CLASS(wxProcessEvent) |
cf447356 | 28 | |
5336ece4 VZ |
29 | public: |
30 | wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0) : wxEvent(id) | |
31 | { | |
32 | m_eventType = wxEVT_END_PROCESS; | |
33 | m_pid = pid; | |
34 | m_exitcode = exitcode; | |
35 | } | |
cf447356 | 36 | |
5336ece4 VZ |
37 | // accessors |
38 | // PID of process which terminated | |
39 | int GetPid() { return m_pid; } | |
cf447356 | 40 | |
5336ece4 VZ |
41 | // the exit code |
42 | int GetExitCode() { return m_exitcode; } | |
cf447356 | 43 | |
5336ece4 VZ |
44 | public: |
45 | int m_pid, m_exitcode; | |
46 | }; | |
cf447356 | 47 | |
5336ece4 VZ |
48 | // A wxProcess object should be passed to wxExecute - than its OnTerminate() |
49 | // function will be called when the process terminates. | |
50 | class WXDLLEXPORT wxProcess : public wxEvtHandler | |
cf447356 | 51 | { |
5336ece4 VZ |
52 | DECLARE_DYNAMIC_CLASS(wxProcess) |
53 | ||
54 | public: | |
8b33ae2d GL |
55 | wxProcess(wxEvtHandler *parent = (wxEvtHandler *) NULL, bool needPipe = FALSE, int id = -1); |
56 | ~wxProcess(); | |
cf447356 | 57 | |
5336ece4 | 58 | virtual void OnTerminate(int pid, int status); |
cf447356 | 59 | |
7e84f02d VZ |
60 | // detach from the parent - should be called by the parent if it's deleted |
61 | // before the process it started terminates | |
62 | void Detach(); | |
63 | ||
8b33ae2d GL |
64 | // Pipe handling |
65 | wxInputStream *GetInputStream() const; | |
66 | wxOutputStream *GetOutputStream() const; | |
67 | ||
68 | // These functions should not be called by the usual user. They are only | |
69 | // intended to be used by wxExecute. | |
70 | // Install pipes | |
71 | void SetPipeStreams(wxInputStream *in_stream, wxOutputStream *out_stream); | |
72 | bool NeedPipe() const; | |
73 | ||
5336ece4 VZ |
74 | protected: |
75 | int m_id; | |
8b33ae2d GL |
76 | bool m_needPipe; |
77 | wxInputStream *m_in_stream; | |
78 | wxOutputStream *m_out_stream; | |
cf447356 GL |
79 | }; |
80 | ||
81 | typedef void (wxObject::*wxProcessEventFunction)(wxProcessEvent&); | |
82 | ||
5336ece4 | 83 | #define EVT_END_PROCESS(id, func) { wxEVT_END_PROCESS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxProcessEventFunction) & func, NULL}, |
cf447356 GL |
84 | |
85 | #endif | |
34138703 | 86 | // _WX_PROCESSH__ |