]> git.saurik.com Git - wxWidgets.git/blob - src/common/process.cpp
menu sample added
[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 wxProcess::wxProcess(wxEvtHandler *parent, bool needPipe, int id)
33 {
34 if (parent)
35 SetNextHandler(parent);
36
37 m_id = id;
38 m_needPipe = needPipe;
39 m_in_stream = NULL;
40 m_out_stream = NULL;
41 }
42
43 wxProcess::~wxProcess()
44 {
45 if (m_in_stream)
46 delete m_in_stream;
47 if (m_out_stream)
48 delete m_out_stream;
49 }
50
51 void wxProcess::OnTerminate(int pid, int status)
52 {
53 wxProcessEvent event(m_id, pid, status);
54
55 if ( !ProcessEvent(event) )
56 delete this;
57 //else: the object which processed the event is responsible for deleting
58 // us!
59 }
60
61 void wxProcess::Detach()
62 {
63 SetNextHandler(NULL);
64 }
65
66 void wxProcess::SetPipeStreams(wxInputStream *in_stream, wxOutputStream *out_stream)
67 {
68 m_in_stream = in_stream;
69 m_out_stream = out_stream;
70 }
71
72 wxInputStream *wxProcess::GetInputStream() const
73 {
74 return m_in_stream;
75 }
76
77 wxOutputStream *wxProcess::GetOutputStream() const
78 {
79 return m_out_stream;
80 }
81
82 bool wxProcess::NeedPipe() const
83 {
84 return m_needPipe;
85 }