Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
Loading...
Searching...
No Matches
BinaryReader Class Referenceabstract

Base for the binary readers: file handling plus a ReadEvent() contract. More...

#include <BinaryUtils.hpp>

Inheritance diagram for BinaryReader:

Public Member Functions

 BinaryReader ()
 Construct a reader with no file open.
virtual ~BinaryReader ()
 Closes the file if it is still open.
virtual Bool_t Open (const char *fname)
 Open a binary file for reading.
virtual void Close ()
 Close the file. Safe to call when nothing is open.
Bool_t IsOpen () const
 Whether a file is currently open.
TString GetFileName () const
 Path most recently passed to Open().
Long64_t GetBytesRead () const
 Bytes consumed so far, for progress reporting.
Bool_t IsEOF () const
 Whether the file is exhausted or was never opened.
virtual Bool_t ReadEvent ()=0
 Decode the next record into the derived reader's current event.

Protected Attributes

std::ifstream file
TString filename
Bool_t file_open
Long64_t bytes_read

Detailed Description

Base for the binary readers: file handling plus a ReadEvent() contract.

Derived classes implement ReadEvent() to decode one record into their own current-event object.

Definition at line 54 of file BinaryUtils.hpp.

Constructor & Destructor Documentation

◆ BinaryReader()

BinaryReader::BinaryReader ( )
inline

Construct a reader with no file open.

Definition at line 63 of file BinaryUtils.hpp.

Referenced by CoMPASSReader::CoMPASSReader(), SOLReader::SOLReader(), and WaveDump742Reader::WaveDump742Reader().

◆ ~BinaryReader()

virtual BinaryReader::~BinaryReader ( )
inlinevirtual

Closes the file if it is still open.

Definition at line 66 of file BinaryUtils.hpp.

Member Function Documentation

◆ Close()

virtual void BinaryReader::Close ( )
inlinevirtual

◆ GetBytesRead()

Long64_t BinaryReader::GetBytesRead ( ) const
inline

◆ GetFileName()

TString BinaryReader::GetFileName ( ) const
inline

Path most recently passed to Open().

Definition at line 104 of file BinaryUtils.hpp.

◆ IsEOF()

Bool_t BinaryReader::IsEOF ( ) const
inline

Whether the file is exhausted or was never opened.

Definition at line 109 of file BinaryUtils.hpp.

Referenced by CoMPASSReader::ReadEvent(), SOLReader::ReadEvent(), and WaveDump742Reader::ReadEvent().

◆ IsOpen()

Bool_t BinaryReader::IsOpen ( ) const
inline

Whether a file is currently open.

Definition at line 102 of file BinaryUtils.hpp.

◆ Open()

virtual Bool_t BinaryReader::Open ( const char * fname)
inlinevirtual

Open a binary file for reading.

Parameters
fnamePath to the file.
Returns
kTRUE on success; kFALSE if the file cannot be opened, with the reason printed to stderr.

Reimplemented in CoMPASSReader.

Definition at line 78 of file BinaryUtils.hpp.

Referenced by InitUtils::ConvertSOLBinToHits(), InitUtils::ConvertSOLBinToROOT(), InitUtils::ConvertWavedumpBinToROOT(), CoMPASSReader::Open(), and CoMPASSReader::Open().

◆ ReadEvent()

virtual Bool_t BinaryReader::ReadEvent ( )
pure virtual

Decode the next record into the derived reader's current event.

Returns
kTRUE if a record was read; kFALSE at end of file or on a malformed record.

Implemented in CoMPASSReader, SOLReader, and WaveDump742Reader.

Member Data Documentation

◆ bytes_read

◆ file

◆ file_open

Bool_t BinaryReader::file_open
protected

Definition at line 58 of file BinaryUtils.hpp.

Referenced by BinaryReader(), Close(), IsEOF(), IsOpen(), and Open().

◆ filename

TString BinaryReader::filename
protected

Definition at line 57 of file BinaryUtils.hpp.

Referenced by GetFileName(), and Open().


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