Panda3D
 All Classes Functions Variables Enumerations
multiplexStream.I
00001 // Filename: multiplexStream.I
00002 // Created by:  drose (27Nov00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 ////////////////////////////////////////////////////////////////////
00016 //     Function: MultiplexStream::Constructor
00017 //       Access: Public
00018 //  Description:
00019 ////////////////////////////////////////////////////////////////////
00020 INLINE MultiplexStream::
00021 MultiplexStream() : ostream(&_msb) {
00022   setf(ios::unitbuf);
00023 }
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: MultiplexStream::add_ostream
00027 //       Access: Public
00028 //  Description: Adds the indicated generic ostream to the multiplex
00029 //               output.  The ostream will receive whatever data is
00030 //               sent to the pipe.
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE void MultiplexStream::
00033 add_ostream(ostream *out, bool delete_later) {
00034   _msb.add_output(MultiplexStreamBuf::BT_none,
00035                   MultiplexStreamBuf::OT_ostream,
00036                   out, NULL, delete_later);
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: MultiplexStream::add_stdio_file
00041 //       Access: Public
00042 //  Description: Adds the given file, previously opened using the C
00043 //               stdio library, to the multiplex output.
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE bool MultiplexStream::
00046 add_stdio_file(FILE *fout, bool close_when_done) {
00047   _msb.add_output(MultiplexStreamBuf::BT_line,
00048                   MultiplexStreamBuf::OT_ostream,
00049                   NULL, fout, close_when_done);
00050   return true;
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: MultiplexStream::add_standard_output
00055 //       Access: Public
00056 //  Description: Adds the standard output channel.
00057 ////////////////////////////////////////////////////////////////////
00058 INLINE void MultiplexStream::
00059 add_standard_output() {
00060   _msb.add_output(MultiplexStreamBuf::BT_none,
00061                   MultiplexStreamBuf::OT_ostream,
00062                   &cout, NULL, false);
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: MultiplexStream::add_file
00067 //       Access: Public
00068 //  Description: Adds the given file to the multiplex output.  The
00069 //               file is opened in append mode with line buffering.
00070 //               Returns false if the file cannot be opened.
00071 ////////////////////////////////////////////////////////////////////
00072 INLINE bool MultiplexStream::
00073 add_file(Filename file) {
00074   file.set_text();
00075   pofstream *out = new pofstream;
00076   if (!file.open_append(*out)) {
00077     delete out;
00078     return false;
00079   }
00080   out->setf(ios::unitbuf);
00081 
00082   _msb.add_output(MultiplexStreamBuf::BT_line,
00083                   MultiplexStreamBuf::OT_ostream,
00084                   out, NULL, true);
00085   return true;
00086 }
00087 
00088 ////////////////////////////////////////////////////////////////////
00089 //     Function: MultiplexStream::add_system_debug
00090 //       Access: Public
00091 //  Description: Adds the system debug output the the multiplex
00092 //               output.  This may map to a syslog or some such
00093 //               os-specific output system.  It may do nothing on a
00094 //               particular system.
00095 //
00096 //               Presently, this maps only to OutputDebugString() on
00097 //               Windows.
00098 ////////////////////////////////////////////////////////////////////
00099 INLINE void MultiplexStream::
00100 add_system_debug() {
00101   _msb.add_output(MultiplexStreamBuf::BT_line,
00102                   MultiplexStreamBuf::OT_system_debug);
00103 }
00104 
00105 ////////////////////////////////////////////////////////////////////
00106 //     Function: MultiplexStream::flush
00107 //       Access: Public
00108 //  Description: Forces out all output that hasn't yet been written.
00109 ////////////////////////////////////////////////////////////////////
00110 INLINE void MultiplexStream::
00111 flush() {
00112   _msb.flush();
00113 }
 All Classes Functions Variables Enumerations