oct-procbuf.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 // This class is based on the procbuf class from libg++, written by
00024 // Per Bothner, Copyright (C) 1993 Free Software Foundation.
00025 
00026 #if !defined (octave_octave_procbuf_h)
00027 #define octave_octave_procbuf_h 1
00028 
00029 #include <sys/types.h>
00030 
00031 #include "c-file-ptr-stream.h"
00032 
00033 class
00034 octave_procbuf : public c_file_ptr_buf
00035 {
00036 public:
00037 
00038   octave_procbuf (void)
00039     : c_file_ptr_buf (0), wstatus (-1), open_p (false), proc_pid (-1),
00040       next (0) { }
00041 
00042   octave_procbuf (const char *command, int mode)
00043     : c_file_ptr_buf (0), wstatus (-1), open_p (false), proc_pid (-1),
00044       next (0) { open (command, mode); }
00045 
00046   ~octave_procbuf (void) { close (); }
00047 
00048   octave_procbuf *open (const char *command, int mode);
00049 
00050   octave_procbuf *close (void);
00051 
00052   int wait_status (void) const { return wstatus; }
00053 
00054   bool is_open (void) const { return open_p; }
00055 
00056   pid_t pid (void) const { return proc_pid; }
00057 
00058 protected:
00059 
00060   int wstatus;
00061 
00062   bool open_p;
00063 
00064   pid_t proc_pid;
00065 
00066   octave_procbuf *next;
00067 
00068 private:
00069 
00070   // No copying!
00071 
00072   octave_procbuf (const octave_procbuf&);
00073 
00074   octave_procbuf& operator = (const octave_procbuf&);
00075 };
00076 
00077 extern void symbols_of_oct_procbuf (void);
00078 
00079 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines