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