Panda3D
|
This class can be used to write a binary file that consists of an arbitrary header followed by a number of datagrams. More...
#include "datagramOutputFile.h"
Public Member Functions | |
void | close () |
Closes the file. | |
virtual void | flush () |
Ensures that all datagrams previously written will be visible in the output file. | |
virtual bool | is_error () |
Returns true if the file has reached an error condition. | |
bool | open (ostream &out) |
Starts writing to the indicated stream. | |
bool | open (Filename filename) |
Opens the indicated filename for reading. | |
virtual bool | put_datagram (const Datagram &data) |
Writes the given datagram to the file. | |
bool | write_header (const string &header) |
Writes a sequence of bytes to the beginning of the datagram file. |
This class can be used to write a binary file that consists of an arbitrary header followed by a number of datagrams.
Definition at line 29 of file datagramOutputFile.h.
void DatagramOutputFile::close | ( | ) |
Closes the file.
This is also implicitly done when the DatagramOutputFile destructs.
Definition at line 73 of file datagramOutputFile.cxx.
Referenced by RecorderController::close(), BamFile::close(), and open().
void DatagramOutputFile::flush | ( | void | ) | [virtual] |
Ensures that all datagrams previously written will be visible in the output file.
Implements DatagramSink.
Definition at line 151 of file datagramOutputFile.cxx.
bool DatagramOutputFile::is_error | ( | ) | [virtual] |
Returns true if the file has reached an error condition.
Implements DatagramSink.
Definition at line 133 of file datagramOutputFile.cxx.
Referenced by RecorderController::is_error().
bool DatagramOutputFile::open | ( | ostream & | out | ) |
Starts writing to the indicated stream.
Returns true on success, false on failure. The DatagramOutputFile does not take ownership of the stream; you are responsible for closing or deleting it when you are done.
Definition at line 57 of file datagramOutputFile.cxx.
References close().
bool DatagramOutputFile::open | ( | Filename | filename | ) |
Opens the indicated filename for reading.
Returns true if successful, false on failure.
Definition at line 26 of file datagramOutputFile.cxx.
References close(), Filename::get_extension(), Filename::open_write(), and Filename::set_binary().
Referenced by RecorderController::begin_record(), TypedWritable::encode_to_bam_stream(), NodePath::encode_to_bam_stream(), BamFile::open_write(), and BamCache::store().
bool DatagramOutputFile::put_datagram | ( | const Datagram & | data | ) | [virtual] |
Writes the given datagram to the file.
Returns true on success, false if there is an error.
Implements DatagramSink.
Definition at line 111 of file datagramOutputFile.cxx.
References StreamWriter::add_uint32(), Datagram::get_data(), and Datagram::get_length().
Referenced by NodePath::encode_to_bam_stream().
bool DatagramOutputFile::write_header | ( | const string & | header | ) |
Writes a sequence of bytes to the beginning of the datagram file.
This may be called any number of times after the file has been opened and before the first datagram is written. It may not be called once the first datagram is written.
Definition at line 95 of file datagramOutputFile.cxx.
Referenced by RecorderController::begin_record(), TypedWritable::encode_to_bam_stream(), NodePath::encode_to_bam_stream(), and BamCache::store().