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. More... | |
virtual bool | copy_datagram (SubfileInfo &result, const Filename &filename) |
Copies the file data from the entire indicated file (via the vfs) as the next datagram. More... | |
virtual bool | copy_datagram (SubfileInfo &result, const SubfileInfo &source) |
Copies the file data from the range of the indicated file (outside of the vfs) as the next datagram. More... | |
virtual void | flush () |
Ensures that all datagrams previously written will be visible in the output file. More... | |
virtual const FileReference * | get_file () |
Returns the FileReference that provides the target for these datagrams, if any, or NULL if the datagrams do not written to a file on disk. More... | |
virtual std::streampos | get_file_pos () |
Returns the current file position within the data stream, if any, or 0 if the file position is not meaningful or cannot be determined. More... | |
virtual const Filename & | get_filename () |
Returns the filename that provides the target for these datagrams, if any, or empty string if the datagrams do not get written to a file on disk. More... | |
std::ostream & | get_stream () |
virtual bool | is_error () |
Returns true if the file has reached an error condition. More... | |
bool | open (const FileReference *file) |
Opens the indicated filename for writing. More... | |
bool | open (const Filename &filename) |
Opens the indicated filename for writing. More... | |
bool | open (std::ostream &out, const Filename &filename=Filename()) |
Starts writing to the indicated stream. More... | |
virtual bool | put_datagram (const Datagram &data) |
Writes the given datagram to the file. More... | |
bool | write_header (const std::string &header) |
Writes a sequence of bytes to the beginning of the datagram file. More... | |
Public Member Functions inherited from DatagramSink | |
DatagramSink () | |
Does nothing since this is class is just the definition of an interface. More... | |
virtual | ~DatagramSink () |
Does nothing since this is class is just the definition of an interface. More... | |
Public Attributes | |
get_stream | |
Returns the ostream represented by the output file. More... | |
Public Attributes inherited from DatagramSink | |
get_file | |
Returns the FileReference that provides the target for these datagrams, if any, or NULL if the datagrams do not written to a file on disk. More... | |
get_file_pos | |
Returns the current file position within the data stream, if any, or 0 if the file position is not meaningful or cannot be determined. More... | |
get_filename | |
Returns the filename that provides the target for these datagrams, if any, or empty string if the datagrams do not get written to a file on disk. More... | |
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 30 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().
|
virtual |
Copies the file data from the entire indicated file (via the vfs) as the next datagram.
This is intended to support potentially very large datagrams.
Returns true on success, false on failure or if this method is unimplemented. On true, fills "result" with the information that references the copied file, if possible.
Reimplemented from DatagramSink.
Definition at line 143 of file datagramOutputFile.cxx.
|
virtual |
Copies the file data from the range of the indicated file (outside of the vfs) as the next datagram.
This is intended to support potentially very large datagrams.
Returns true on success, false on failure or if this method is unimplemented. On true, fills "result" with the information that references the copied file, if possible.
Reimplemented from DatagramSink.
Definition at line 212 of file datagramOutputFile.cxx.
|
virtual |
Ensures that all datagrams previously written will be visible in the output file.
Implements DatagramSink.
Definition at line 283 of file datagramOutputFile.cxx.
|
virtual |
Returns the FileReference that provides the target for these datagrams, if any, or NULL if the datagrams do not written to a file on disk.
Reimplemented from DatagramSink.
Definition at line 304 of file datagramOutputFile.cxx.
|
virtual |
Returns the current file position within the data stream, if any, or 0 if the file position is not meaningful or cannot be determined.
For DatagramOutputFiles that return a meaningful file position, this will be pointing to the first byte following the datagram returned after a call to put_datagram().
Reimplemented from DatagramSink.
Definition at line 317 of file datagramOutputFile.cxx.
|
virtual |
Returns the filename that provides the target for these datagrams, if any, or empty string if the datagrams do not get written to a file on disk.
Reimplemented from DatagramSink.
Definition at line 295 of file datagramOutputFile.cxx.
|
virtual |
Returns true if the file has reached an error condition.
Implements DatagramSink.
Definition at line 267 of file datagramOutputFile.cxx.
Referenced by RecorderController::is_error().
bool DatagramOutputFile::open | ( | const FileReference * | file | ) |
Opens the indicated filename for writing.
Returns true if successful, false on failure.
Definition at line 28 of file datagramOutputFile.cxx.
References close(), and Filename::set_binary().
Referenced by RecorderController::begin_record(), open(), and BamFile::open_write().
|
inline |
Opens the indicated filename for writing.
Returns true on success, false on failure.
Definition at line 38 of file datagramOutputFile.I.
References open().
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 54 of file datagramOutputFile.cxx.
References close().
|
virtual |
Writes the given datagram to the file.
Returns true on success, false if there is an error.
Implements DatagramSink.
Definition at line 110 of file datagramOutputFile.cxx.
bool DatagramOutputFile::write_header | ( | const std::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 96 of file datagramOutputFile.cxx.
Referenced by RecorderController::begin_record().
|
inline |
Returns the ostream represented by the output file.
Definition at line 56 of file datagramOutputFile.h.