Pottu
Public Member Functions | List of all members
pottu::FileReader Class Reference

Datasource which reads TDR data from a disk. More...

#include <FileReader.hpp>

Inheritance diagram for pottu::FileReader:
Inheritance graph
[legend]
Collaboration diagram for pottu::FileReader:
Collaboration graph
[legend]

Public Member Functions

 FileReader (uint32_t blocksAtOnce=1)
 Construct the Filereader object. More...
 
void addFile (const std::string &filename)
 Adds a new TDR file into the queue. More...
 
virtual void process (std::vector< dataitem_t > &dp)
 Reads data from file to a container. More...
 
virtual bool allDone () const noexcept
 Tells if all the files are processed. More...
 
uint64_t getBlocksRead () const
 Returns number of blocks read. More...
 
uint64_t getTotalBytesRead () const
 Returns number of total bytes read this far by this object. More...
 
uint64_t getTotalBytesReadFromFile () const
 Returns number of total bytes read from all files without unpacking. More...
 
double getProgress () const noexcept
 Returns the fraction of read unpacked bytes to the total size of the all files queued. More...
 
void setProgressReport (bool state=true) noexcept
 Sets the state of automatic progress reporting. More...
 
bool getProgressReport () const noexcept
 Returns the state of automatic progress reporting. More...
 
- Public Member Functions inherited from pottu::DataSource
virtual ~DataSource ()
 Virtual destructor.
 

Detailed Description

Datasource which reads TDR data from a disk.

New files can be added to a queue by calling addFile(). File is checked to be a valid TDR file in that moment. Filereader handles gzipped TDR files automatically. After the last file is fully consumed the method allDone() will return true.

Constructor & Destructor Documentation

◆ FileReader()

pottu::FileReader::FileReader ( uint32_t  blocksAtOnce = 1)
inline

Construct the Filereader object.

Parameters
blocksAtOnceMaximum number of datablocks the filereader reads and pushes to output in each call to process(). Default is one.

Member Function Documentation

◆ addFile()

void pottu::FileReader::addFile ( const std::string &  filename)
inline

Adds a new TDR file into the queue.

Parameters
filenameFilename of the file to be added.

This method can be used for both normal and gzipped files. The method opens the file and checks that it is a valid TDR file. Also the total size of the files is incremented.

◆ allDone()

virtual bool pottu::FileReader::allDone ( ) const
inlinevirtualnoexcept

Tells if all the files are processed.

Returns
True if there is nothing to return anymore by method process().

Implements pottu::DataSource.

◆ getBlocksRead()

uint64_t pottu::FileReader::getBlocksRead ( ) const
inline

Returns number of blocks read.

Returns
Number of blocks read.

◆ getProgress()

double pottu::FileReader::getProgress ( ) const
inlinenoexcept

Returns the fraction of read unpacked bytes to the total size of the all files queued.

Returns
The fraction of read unpacked bytes to the total size of the all files queued. Should be unity when the method allDone() returns true.

◆ getProgressReport()

bool pottu::FileReader::getProgressReport ( ) const
inlinenoexcept

Returns the state of automatic progress reporting.

Returns
Current state of the automatic progress reporting.

◆ getTotalBytesRead()

uint64_t pottu::FileReader::getTotalBytesRead ( ) const
inline

Returns number of total bytes read this far by this object.

Returns
Number of total bytes read this far by this object.

Note that these bytes are extracted ungzipped bytes i.e. can be more than the file bytes consumed.

◆ getTotalBytesReadFromFile()

uint64_t pottu::FileReader::getTotalBytesReadFromFile ( ) const
inline

Returns number of total bytes read from all files without unpacking.

Returns
Number of total bytes read from the filesystem without unpacking.

This returns the same number as getTotalBytesRead() if the file is not gzipped.

◆ process()

virtual void pottu::FileReader::process ( std::vector< dataitem_t > &  dp)
inlinevirtual

Reads data from file to a container.

Parameters
dpContainer to be filled with raw dataitems read from file.

Container dp is always cleared by process() before adding new items.

Implements pottu::DataSource.

◆ setProgressReport()

void pottu::FileReader::setProgressReport ( bool  state = true)
inlinenoexcept

Sets the state of automatic progress reporting.

Parameters
stateSet to true (default) if you want an automatic progress report every 2 seconds into the console.

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