*** empty log message ***

This commit is contained in:
David Rose 2000-12-05 02:54:48 +00:00
parent 8b56b102e3
commit d5eca5fa6f
7 changed files with 89 additions and 8 deletions

View File

@ -187,7 +187,7 @@ public:
};
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);

View File

@ -24,7 +24,21 @@ INLINE void MultiplexStream::
add_ostream(ostream *out, bool delete_later) {
_msb.add_output(MultiplexStreamBuf::BT_none,
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() {
_msb.add_output(MultiplexStreamBuf::BT_none,
MultiplexStreamBuf::OT_ostream,
&cout, false);
&cout, NULL, false);
}
////////////////////////////////////////////////////////////////////
@ -58,7 +72,7 @@ add_file(Filename file) {
_msb.add_output(MultiplexStreamBuf::BT_line,
MultiplexStreamBuf::OT_ostream,
out, true);
out, NULL, true);
return true;
}

View File

@ -12,6 +12,8 @@
#include <filename.h>
#include <stdio.h>
////////////////////////////////////////////////////////////////////
// Class : MultiplexStream
// Description : This is a special ostream that forwards the data that
@ -26,6 +28,7 @@ PUBLISHED:
INLINE MultiplexStream();
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 bool add_file(Filename file);
INLINE void add_system_debug();

View File

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

View File

@ -21,6 +21,32 @@
typedef int streamsize;
#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
// Access: Public
@ -32,6 +58,13 @@ write_string(const string &str) {
case OT_ostream:
assert(_out != (ostream *)NULL);
_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;
case OT_system_debug:
@ -65,6 +98,13 @@ MultiplexStreamBuf() {
MultiplexStreamBuf::
~MultiplexStreamBuf() {
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();
}
}
////////////////////////////////////////////////////////////////////

View File

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

View File

@ -85,6 +85,7 @@
#include <collisionTraverser.h>
#include <collisionHandlerFloor.h>
#include <nodePath.h>
#include <multiplexStream.h>
#ifdef USE_IPC
#include <ipc_file.h>
@ -875,6 +876,23 @@ void event_x(CPT_Event) {
int framework_main(int argc, char *argv[]) {
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();
#ifndef DEBUG