]> git.saurik.com Git - wxWidgets.git/blob - src/common/process.cpp
added English and English US for testing
[wxWidgets.git] / src / common / process.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: process.cpp
3 // Purpose: Process termination classes
4 // Author: Guilhem Lavaux
5 // Modified by: Vadim Zeitlin to check error codes, added Detach() method
6 // Created: 24/06/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "process.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/defs.h"
25 #endif
26
27 #include "wx/process.h"
28
29 IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
30 IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent)
31
32 void wxProcess::Init(wxEvtHandler *parent, int id, bool redirect)
33 {
34 if ( parent )
35 SetNextHandler(parent);
36
37 m_id = id;
38 m_redirect = redirect;
39
40 #if wxUSE_STREAMS
41 m_inputStream = NULL;
42 m_errorStream = NULL;
43 m_outputStream = NULL;
44 #endif // wxUSE_STREAMS
45 }
46
47 wxProcess::~wxProcess()
48 {
49 #if wxUSE_STREAMS
50 delete m_inputStream;
51 delete m_errorStream;
52 delete m_outputStream;
53 #endif // wxUSE_STREAMS
54 }
55
56 void wxProcess::OnTerminate(int pid, int status)
57 {
58 wxProcessEvent event(m_id, pid, status);
59
60 if ( !ProcessEvent(event) )
61 delete this;
62 //else: the object which processed the event is responsible for deleting
63 // us!
64 }
65
66 void wxProcess::Detach()
67 {
68 SetNextHandler(NULL);
69 }
70
71 #if wxUSE_STREAMS
72
73 void wxProcess::SetPipeStreams(wxInputStream *inputSstream,
74 wxOutputStream *outputStream,
75 wxInputStream *errorStream)
76 {
77 m_inputStream = inputSstream;
78 m_errorStream = errorStream;
79 m_outputStream = outputStream;
80 }
81
82 #endif // wxUSE_STREAMS