gem5
v20.1.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. More... | |
~ProtoOutputStream () | |
Destruct the output stream, and also flush and close the underlying file streams and coded streams. More... | |
void | write (const google::protobuf::Message &msg) |
Write a message to the stream, preprending it with the message size. More... | |
Private Attributes | |
std::ofstream | fileStream |
Underlying file output stream. More... | |
google::protobuf::io::OstreamOutputStream * | wrappedFileStream |
Zero Copy stream wrapping the STL output stream. More... | |
google::protobuf::io::GzipOutputStream * | gzipStream |
Optional Gzip stream to wrap the Zero Copy stream. More... | |
google::protobuf::io::ZeroCopyOutputStream * | zeroCopyStream |
Top-level zero-copy stream, either with compression or not. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ProtoStream | |
ProtoStream () | |
Create a ProtoStream. More... | |
Static Protected Attributes inherited from ProtoStream | |
static const uint32_t | magicNumber = 0x356d6567 |
Use the ASCII characters gem5 as our magic number. More... | |
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 45 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 72 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 82 of file protoio.cc.
References zeroCopyStream.
Referenced by Trace::InstPBTrace::closeStreams(), Trace::InstPBTrace::createTraceFile(), ElasticTrace::fetchReqTrace(), MemTraceProbe::handleRequest(), MemTraceProbe::startup(), Trace::InstPBTrace::traceInst(), and 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().