VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
vrs::RecordReader Class Referenceabstract

Abstract VRS internal helper class to read & (if necessary) uncompress records. More...

#include <RecordReaders.h>

Inheritance diagram for vrs::RecordReader:
vrs::CompressedRecordReader vrs::UncompressedRecordReader

Public Member Functions

RecordReaderinit (FileHandler &file, uint32_t diskSize, uint32_t expandedSize)
 
virtual int read (DataReference &destination, uint32_t &outReadSize)=0
 
template<typename T , std::enable_if_t< std::is_trivially_copyable< T >::value, int > = 0>
int read (std::vector< T > &buffer)
 
int read (void *destination, size_t size)
 
virtual void finish ()
 Discard any unread data.
 
uint32_t getUnreadDiskBytes () const
 
uint32_t getUnreadBytes () const
 
int64_t getFileOffset () const
 
virtual CompressionType getCompressionType () const =0
 
const void * getRef () const
 

Protected Attributes

FileHandlerfile_
 
uint32_t remainingDiskBytes_
 
uint32_t remainingUncompressedSize_
 

Detailed Description

Abstract VRS internal helper class to read & (if necessary) uncompress records.

Member Function Documentation

◆ finish()

virtual void vrs::RecordReader::finish ( )
inlinevirtual

Discard any unread data.

Reimplemented in vrs::CompressedRecordReader.

◆ getCompressionType()

virtual CompressionType vrs::RecordReader::getCompressionType ( ) const
pure virtual

Tell if/how the record was compressed.

Returns
The compression type.

Implemented in vrs::UncompressedRecordReader, and vrs::CompressedRecordReader.

◆ getUnreadBytes()

uint32_t vrs::RecordReader::getUnreadBytes ( ) const
inline

Tell how many bytes of record data haven't been read/consumed yet.

Returns
Number of unread bytes (uncompressed).

◆ getUnreadDiskBytes()

uint32_t vrs::RecordReader::getUnreadDiskBytes ( ) const
inline

Tell how many disk bytes of record data haven't been read/consumed yet.

Returns
Number of unread disk bytes.

◆ init()

RecordReader * vrs::RecordReader::init ( FileHandler file,
uint32_t  diskSize,
uint32_t  expandedSize 
)

Initialize the RecordReader to read a record from a file.

Parameters
fileFile to read from, ready to read the record at the current file position.
diskSizeSize of the record on disk.
expandedSizeSize of the record uncompressed.
Returns
Pointer to the reader.

◆ read() [1/3]

virtual int vrs::RecordReader::read ( DataReference destination,
uint32_t &  outReadSize 
)
pure virtual

Read data to a DataReference.

Parameters
destinationDataReference to read data to.
outReadSizeReference to set to the number of bytes read.
Returns
0 on success, or a non-zero error code.

Implemented in vrs::UncompressedRecordReader, and vrs::CompressedRecordReader.

◆ read() [2/3]

template<typename T , std::enable_if_t< std::is_trivially_copyable< T >::value, int > = 0>
int vrs::RecordReader::read ( std::vector< T > &  buffer)
inline

Fill-up a buffer. Might reduce the buffer's size, if not enough data was available.

Parameters
bufferReference to a buffer of bytes to fill-up.
Returns
0 on success, or a non-zero error code.

◆ read() [3/3]

int vrs::RecordReader::read ( void *  destination,
size_t  size 
)
inline

Read a number of bytes to the destination buffer. If the record is compressed, the data is uncompressed.

Parameters
destinationPointer to the buffer where to write the read data.
sizeNumber of bytes to read.
Returns
0 on success, or a non-zero error code.

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