gem5 v24.0.0.0
Loading...
Searching...
No Matches
ProtoInputStream Class Reference

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

#include <protoio.hh>

Inheritance diagram for ProtoInputStream:
ProtoStream

Public Member Functions

 ProtoInputStream (const std::string &filename)
 Create an input stream for a given file name.
 
 ~ProtoInputStream ()
 Destruct the input stream, and also close the underlying file streams and coded streams.
 
bool read (google::protobuf::Message &msg)
 Read a message from the stream.
 
void reset ()
 Reset the input stream and seek to the beginning of the file.
 

Private Member Functions

void createStreams ()
 Create the internal streams that are wrapping the input file.
 
void destroyStreams ()
 Destroy the internal streams that are wrapping the input file.
 

Private Attributes

std::ifstream fileStream
 Underlying file input stream.
 
const std::string fileName
 Hold on to the file name for debug messages.
 
bool useGzip
 Boolean flag to remember whether we use gzip or not.
 
google::protobuf::io::IstreamInputStream * wrappedFileStream
 Zero Copy stream wrapping the STL input stream.
 
google::protobuf::io::GzipInputStream * gzipStream
 Optional Gzip stream to wrap the Zero Copy stream.
 
google::protobuf::io::ZeroCopyInputStream * 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.
 

Detailed Description

A ProtoInputStream wraps a coded stream, potentially with decompression, based on looking at the file name.

Reading from the stream is done on a per-message basis to avoid having to deal with huge data structures. The latter assumes the length of each message is encoded in the stream when it is written.

Definition at line 140 of file protoio.hh.

Constructor & Destructor Documentation

◆ ProtoInputStream()

ProtoInputStream::ProtoInputStream ( const std::string & filename)

Create an input stream for a given file name.

If the filename ends with .gz then the file will be decompressed accordingly.

Parameters
filenamePath to the file to read from

Definition at line 103 of file protoio.cc.

References createStreams(), fileStream, panic, and useGzip.

◆ ~ProtoInputStream()

ProtoInputStream::~ProtoInputStream ( )

Destruct the input stream, and also close the underlying file streams and coded streams.

Definition at line 164 of file protoio.cc.

References destroyStreams(), and fileStream.

Member Function Documentation

◆ createStreams()

void ProtoInputStream::createStreams ( )
private

Create the internal streams that are wrapping the input file.

Definition at line 124 of file protoio.cc.

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

Referenced by ProtoInputStream(), and reset().

◆ destroyStreams()

void ProtoInputStream::destroyStreams ( )
private

Destroy the internal streams that are wrapping the input file.

Definition at line 150 of file protoio.cc.

References gzipStream, wrappedFileStream, and zeroCopyStream.

Referenced by reset(), and ~ProtoInputStream().

◆ read()

bool ProtoInputStream::read ( google::protobuf::Message & msg)

Read a message from the stream.

Parameters
msgMessage read from the stream
returnTrue if a message was read, false if reading fails

Definition at line 182 of file protoio.cc.

References fileName, panic, and zeroCopyStream.

Referenced by gem5::TraceCPU::ElasticDataGen::InputStream::InputStream(), and gem5::TraceCPU::FixedRetryGen::InputStream::InputStream().

◆ reset()

void ProtoInputStream::reset ( )

Reset the input stream and seek to the beginning of the file.

Definition at line 172 of file protoio.cc.

References createStreams(), destroyStreams(), and fileStream.

Member Data Documentation

◆ fileName

const std::string ProtoInputStream::fileName
private

Hold on to the file name for debug messages.

Definition at line 188 of file protoio.hh.

Referenced by createStreams(), and read().

◆ fileStream

std::ifstream ProtoInputStream::fileStream
private

Underlying file input stream.

Definition at line 185 of file protoio.hh.

Referenced by createStreams(), ProtoInputStream(), reset(), and ~ProtoInputStream().

◆ gzipStream

google::protobuf::io::GzipInputStream* ProtoInputStream::gzipStream
private

Optional Gzip stream to wrap the Zero Copy stream.

Definition at line 197 of file protoio.hh.

Referenced by createStreams(), and destroyStreams().

◆ useGzip

bool ProtoInputStream::useGzip
private

Boolean flag to remember whether we use gzip or not.

Definition at line 191 of file protoio.hh.

Referenced by createStreams(), and ProtoInputStream().

◆ wrappedFileStream

google::protobuf::io::IstreamInputStream* ProtoInputStream::wrappedFileStream
private

Zero Copy stream wrapping the STL input stream.

Definition at line 194 of file protoio.hh.

Referenced by createStreams(), and destroyStreams().

◆ zeroCopyStream

google::protobuf::io::ZeroCopyInputStream* ProtoInputStream::zeroCopyStream
private

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

Definition at line 200 of file protoio.hh.

Referenced by createStreams(), destroyStreams(), and read().


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

Generated on Tue Jun 18 2024 16:24:09 for gem5 by doxygen 1.11.0