Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
d5eca5fa6f

+ 1 - 1
panda/src/egg/eggTexture.h

@@ -187,7 +187,7 @@ public:
 };
 };
 
 
 INLINE ostream &operator << (ostream &out, const EggTexture &n) {
 INLINE ostream &operator << (ostream &out, const EggTexture &n) {
-  return out << (Filename &)n;
+  return out << n.get_filename();
 }
 }
 
 
 ostream EXPCL_PANDAEGG &operator << (ostream &out, EggTexture::Format format);
 ostream EXPCL_PANDAEGG &operator << (ostream &out, EggTexture::Format format);

+ 17 - 3
panda/src/express/multiplexStream.I

@@ -24,7 +24,21 @@ INLINE void MultiplexStream::
 add_ostream(ostream *out, bool delete_later) {
 add_ostream(ostream *out, bool delete_later) {
   _msb.add_output(MultiplexStreamBuf::BT_none, 
   _msb.add_output(MultiplexStreamBuf::BT_none, 
 		  MultiplexStreamBuf::OT_ostream,
 		  MultiplexStreamBuf::OT_ostream,
-		  out, delete_later);
+		  out, NULL, delete_later);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MultiplexStream::add_stdio_file
+//       Access: Public
+//  Description: Adds the given file, previously opened using the C
+//               stdio library, to the multiplex output.
+////////////////////////////////////////////////////////////////////
+INLINE bool MultiplexStream::
+add_stdio_file(FILE *fout, bool close_when_done) {
+  _msb.add_output(MultiplexStreamBuf::BT_line, 
+		  MultiplexStreamBuf::OT_ostream,
+		  NULL, fout, close_when_done);
+  return true;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -36,7 +50,7 @@ INLINE void MultiplexStream::
 add_standard_output() {
 add_standard_output() {
   _msb.add_output(MultiplexStreamBuf::BT_none, 
   _msb.add_output(MultiplexStreamBuf::BT_none, 
 		  MultiplexStreamBuf::OT_ostream,
 		  MultiplexStreamBuf::OT_ostream,
-		  &cout, false);
+		  &cout, NULL, false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -58,7 +72,7 @@ add_file(Filename file) {
 
 
   _msb.add_output(MultiplexStreamBuf::BT_line, 
   _msb.add_output(MultiplexStreamBuf::BT_line, 
 		  MultiplexStreamBuf::OT_ostream,
 		  MultiplexStreamBuf::OT_ostream,
-		  out, true);
+		  out, NULL, true);
   return true;
   return true;
 }
 }
 
 

+ 3 - 0
panda/src/express/multiplexStream.h

@@ -12,6 +12,8 @@
 
 
 #include <filename.h>
 #include <filename.h>
 
 
+#include <stdio.h>
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : MultiplexStream
 //       Class : MultiplexStream
 // Description : This is a special ostream that forwards the data that
 // Description : This is a special ostream that forwards the data that
@@ -26,6 +28,7 @@ PUBLISHED:
   INLINE MultiplexStream();
   INLINE MultiplexStream();
 
 
   INLINE void add_ostream(ostream *out, bool delete_later = false);
   INLINE void add_ostream(ostream *out, bool delete_later = false);
+  INLINE bool add_stdio_file(FILE *file, bool close_when_done);
   INLINE void add_standard_output();
   INLINE void add_standard_output();
   INLINE bool add_file(Filename file);
   INLINE bool add_file(Filename file);
   INLINE void add_system_debug();
   INLINE void add_system_debug();

+ 3 - 2
panda/src/express/multiplexStreamBuf.I

@@ -14,12 +14,13 @@
 INLINE void MultiplexStreamBuf::
 INLINE void MultiplexStreamBuf::
 add_output(MultiplexStreamBuf::BufferType buffer_type,
 add_output(MultiplexStreamBuf::BufferType buffer_type,
 	   MultiplexStreamBuf::OutputType output_type,
 	   MultiplexStreamBuf::OutputType output_type,
-	   ostream *out, bool owns_ostream) {
+	   ostream *out, FILE *fout, bool owns_obj) {
   Output o;
   Output o;
   o._buffer_type = buffer_type;
   o._buffer_type = buffer_type;
   o._output_type = output_type;
   o._output_type = output_type;
   o._out = out;
   o._out = out;
-  o._owns_ostream = owns_ostream;
+  o._fout = fout;
+  o._owns_obj = owns_obj;
   _outputs.push_back(o);
   _outputs.push_back(o);
 }
 }
 
 

+ 40 - 0
panda/src/express/multiplexStreamBuf.cxx

@@ -21,6 +21,32 @@
 typedef int streamsize;
 typedef int streamsize;
 #endif
 #endif
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: MultiplexStreamBuf::Output::close
+//       Access: Public
+//  Description: Closes or deletes the relevant pointers, if _owns_obj
+//               is true.
+////////////////////////////////////////////////////////////////////
+void MultiplexStreamBuf::Output::
+close() {
+  if (_owns_obj) {
+    switch (_output_type) {
+    case OT_ostream:
+      assert(_out != (ostream *)NULL);
+      delete _out;
+      break;
+
+    case OT_stdio:
+      assert(_fout != (FILE *)NULL);
+      fclose(_fout);
+      break;
+
+    default:
+      break;
+    }
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MultiplexStreamBuf::Output::write_string
 //     Function: MultiplexStreamBuf::Output::write_string
 //       Access: Public
 //       Access: Public
@@ -32,6 +58,13 @@ write_string(const string &str) {
   case OT_ostream:
   case OT_ostream:
     assert(_out != (ostream *)NULL);
     assert(_out != (ostream *)NULL);
     _out->write(str.data(), str.length());
     _out->write(str.data(), str.length());
+    _out->flush();
+    break;
+
+  case OT_stdio:
+    assert(_fout != (FILE *)NULL);
+    fwrite(str.data(), str.length(), 1, _fout);
+    fflush(_fout);
     break;
     break;
 
 
   case OT_system_debug:
   case OT_system_debug:
@@ -65,6 +98,13 @@ MultiplexStreamBuf() {
 MultiplexStreamBuf::
 MultiplexStreamBuf::
 ~MultiplexStreamBuf() {
 ~MultiplexStreamBuf() {
   sync();
   sync();
+
+  // Make sure all of our owned pointers are freed.
+  Outputs::iterator oi;
+  for (oi = _outputs.begin(); oi != _outputs.end(); ++oi) {
+    Output &out = (*oi);
+    out.close();
+  }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 7 - 2
panda/src/express/multiplexStreamBuf.h

@@ -9,6 +9,7 @@
 #include <pandabase.h>
 #include <pandabase.h>
 
 
 #include <vector>
 #include <vector>
+#include <stdio.h>
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : MultiplexStreamBuf
 //       Class : MultiplexStreamBuf
@@ -28,12 +29,14 @@ public:
 
 
   enum OutputType {
   enum OutputType {
     OT_ostream,
     OT_ostream,
+    OT_stdio,
     OT_system_debug,
     OT_system_debug,
   };
   };
 
 
   INLINE void add_output(BufferType buffer_type, OutputType output_type,
   INLINE void add_output(BufferType buffer_type, OutputType output_type,
 			 ostream *out = (ostream *)NULL, 
 			 ostream *out = (ostream *)NULL, 
-			 bool owns_ostream = false);
+			 FILE *fout = (FILE *)NULL, 
+			 bool owns_obj = false);
 
 
   INLINE void flush();
   INLINE void flush();
 
 
@@ -47,12 +50,14 @@ private:
 
 
   class Output {
   class Output {
   public:
   public:
+    void close();
     void write_string(const string &str);
     void write_string(const string &str);
 
 
     BufferType _buffer_type;
     BufferType _buffer_type;
     OutputType _output_type;
     OutputType _output_type;
     ostream *_out;
     ostream *_out;
-    bool _owns_ostream;
+    FILE *_fout;
+    bool _owns_obj;
   };
   };
 
 
   typedef vector<Output> Outputs;
   typedef vector<Output> Outputs;

+ 18 - 0
panda/src/framework/framework.cxx

@@ -85,6 +85,7 @@
 #include <collisionTraverser.h>
 #include <collisionTraverser.h>
 #include <collisionHandlerFloor.h>
 #include <collisionHandlerFloor.h>
 #include <nodePath.h>
 #include <nodePath.h>
+#include <multiplexStream.h>
 
 
 #ifdef USE_IPC
 #ifdef USE_IPC
 #include <ipc_file.h>
 #include <ipc_file.h>
@@ -875,6 +876,23 @@ void event_x(CPT_Event) {
 int framework_main(int argc, char *argv[]) {
 int framework_main(int argc, char *argv[]) {
   pystub();
   pystub();
 
 
+  // The first thing we should do is to set up a multiplexing Notify.
+  MultiplexStream *mstream = new MultiplexStream;
+  Notify::ptr()->set_ostream_ptr(mstream, true);
+  mstream->add_standard_output();
+  mstream->add_system_debug();
+
+  string framework_notify_output = framework.GetString("framework-notify-output", "");
+  if (!framework_notify_output.empty()) {
+    if (!mstream->add_file(framework_notify_output)) {
+      framework_cat.error()
+	<< "Unable to open " << framework_notify_output << " for output.\n";
+    } else {
+      framework_cat.info() 
+	<< "Sending Notify output to " << framework_notify_output << "\n";
+    }
+  }
+
   GeomNorms::init_type();
   GeomNorms::init_type();
 
 
 #ifndef DEBUG
 #ifndef DEBUG