gem5  v21.1.0.2
Public Member Functions | Private Attributes | List of all members
ProtoOutputStream Class Reference

A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file name. More...

#include <protoio.hh>

Inheritance diagram for ProtoOutputStream:
ProtoStream

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ProtoOutputStream()

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.

Parameters
filenamePath to the file to create or truncate

Definition at line 44 of file protoio.cc.

References fileStream, gzipStream, ProtoStream::magicNumber, panic, wrappedFileStream, and zeroCopyStream.

◆ ~ProtoOutputStream()

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.

Member Function Documentation

◆ write()

void ProtoOutputStream::write ( const google::protobuf::Message &  msg)

Member Data Documentation

◆ fileStream

std::ofstream ProtoOutputStream::fileStream
private

Underlying file output stream.

Definition at line 120 of file protoio.hh.

Referenced by ProtoOutputStream(), and ~ProtoOutputStream().

◆ gzipStream

google::protobuf::io::GzipOutputStream* ProtoOutputStream::gzipStream
private

Optional Gzip stream to wrap the Zero Copy stream.

Definition at line 126 of file protoio.hh.

Referenced by ProtoOutputStream(), and ~ProtoOutputStream().

◆ wrappedFileStream

google::protobuf::io::OstreamOutputStream* ProtoOutputStream::wrappedFileStream
private

Zero Copy stream wrapping the STL output stream.

Definition at line 123 of file protoio.hh.

Referenced by ProtoOutputStream(), and ~ProtoOutputStream().

◆ zeroCopyStream

google::protobuf::io::ZeroCopyOutputStream* ProtoOutputStream::zeroCopyStream
private

Top-level zero-copy stream, either with compression or not.

Definition at line 129 of file protoio.hh.

Referenced by ProtoOutputStream(), and write().


The documentation for this class was generated from the following files:

Generated on Tue Sep 21 2021 12:27:05 for gem5 by doxygen 1.8.17