gem5 v24.0.0.0
|
A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file name. More...
#include <protoio.hh>
Public Member Functions | |
ProtoOutputStream (const std::string &filename) | |
Create an output stream for a given file name. | |
~ProtoOutputStream () | |
Destruct the output stream, and also flush and close the underlying file streams and coded streams. | |
void | write (const google::protobuf::Message &msg) |
Write a message to the stream, preprending it with the message size. | |
Private Attributes | |
std::ofstream | fileStream |
Underlying file output stream. | |
google::protobuf::io::OstreamOutputStream * | wrappedFileStream |
Zero Copy stream wrapping the STL output stream. | |
google::protobuf::io::GzipOutputStream * | gzipStream |
Optional Gzip stream to wrap the Zero Copy stream. | |
google::protobuf::io::ZeroCopyOutputStream * | zeroCopyStream |
Top-level zero-copy stream, either with compression or not. | |
Additional Inherited Members | |
Protected Member Functions inherited from ProtoStream | |
ProtoStream () | |
Create a ProtoStream. | |
Static Protected Attributes inherited from ProtoStream | |
static const uint32_t | magicNumber = 0x356d6567 |
Use the ASCII characters gem5 as our magic number. | |
A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file name.
Writing to the stream is done to enable interaction with the file on a per-message basis to avoid having to deal with huge data structures. The latter is made possible by encoding the length of each message in the stream.
Definition at line 90 of file protoio.hh.
ProtoOutputStream::ProtoOutputStream | ( | const std::string & | filename | ) |
Create an output stream for a given file name.
If the filename ends with .gz then the file will be compressed accordinly.
filename | Path to the file to create or truncate |
Definition at line 46 of file protoio.cc.
References fileStream, gzipStream, ProtoStream::magicNumber, panic, wrappedFileStream, and zeroCopyStream.
ProtoOutputStream::~ProtoOutputStream | ( | ) |
Destruct the output stream, and also flush and close the underlying file streams and coded streams.
Definition at line 74 of file protoio.cc.
References fileStream, gzipStream, and wrappedFileStream.
void ProtoOutputStream::write | ( | const google::protobuf::Message & | msg | ) |
Write a message to the stream, preprending it with the message size.
msg | Message to write to the stream |
Definition at line 84 of file protoio.cc.
References zeroCopyStream.
Referenced by gem5::trace::InstPBTrace::closeStreams(), gem5::trace::InstPBTrace::createTraceFile(), gem5::o3::ElasticTrace::fetchReqTrace(), gem5::MemTraceProbe::handleRequest(), gem5::MemTraceProbe::startup(), gem5::trace::InstPBTrace::traceInst(), and gem5::o3::ElasticTrace::writeDepTrace().
|
private |
Underlying file output stream.
Definition at line 120 of file protoio.hh.
Referenced by ProtoOutputStream(), and ~ProtoOutputStream().
|
private |
Optional Gzip stream to wrap the Zero Copy stream.
Definition at line 126 of file protoio.hh.
Referenced by ProtoOutputStream(), and ~ProtoOutputStream().
|
private |
Zero Copy stream wrapping the STL output stream.
Definition at line 123 of file protoio.hh.
Referenced by ProtoOutputStream(), and ~ProtoOutputStream().
|
private |
Top-level zero-copy stream, either with compression or not.
Definition at line 129 of file protoio.hh.
Referenced by ProtoOutputStream(), and write().