Monarch  v3.8.2
Project 8 Data File Format Library
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
M3Stream Class Reference

Read/write access for a data stream. More...

#include <M3Stream.hh>

Public Types

enum  Mode { kRead, kWrite }
 

Public Member Functions

 M3Stream (const M3StreamHeader &aHeader, HAS_GRP_IFC *aH5StreamParentLoc, uint32_t aAccessFormat=sSeparate)
 
virtual ~M3Stream ()
 
 M3Stream (const M3Stream &)=delete
 
M3Streamoperator= (const M3Stream &)=delete
 
 camel_case_mv_accessible_mutable (Mode, Mode)
 
void Initialize () const
 Setup to read/write data (called in constructor; only call this if read/write parameters change during file reading) More...
 
void SetMutex (const mutex_ptr &aMutexPtr)
 
const M3RecordGetStreamRecord () const
 Get the pointer to the stream record. More...
 
const M3RecordGetChannelRecord (unsigned aChannel) const
 Get the pointer to a particular channel record. More...
 
bool ReadRecord (int anOffset=0, bool aIfNewAcqStartAtFirstRec=true) const
 Read the next record from the file. More...
 
void Close () const
 Close the file. More...
 
M3RecordGetStreamRecord ()
 Get the pointer to the stream record. More...
 
M3RecordGetChannelRecord (unsigned aChannel)
 Get the pointer to a particular channel record. More...
 
bool WriteRecord (bool aIsNewAcquisition)
 Write the record contents to the file. More...
 
void Close ()
 Close the stream. More...
 
bool GetIsInitialized () const
 
bool GetRecordsAccessed () const
 
unsigned GetDataTypeSize () const
 
unsigned GetSampleSize () const
 
unsigned GetStreamRecordNBytes () const
 
unsigned GetStreamRecordSize () const
 
unsigned GetChannelRecordNBytes () const
 
unsigned GetChannelRecordSize () const
 
unsigned GetNChannels () const
 
unsigned GetNAcquisitions () const
 
AcquisitionIdType GetAcquisitionId () const
 
unsigned GetRecordCountInAcq () const
 
unsigned GetNRecordsInAcquisition () const
 
TimeType GetAcqFirstRecordTime () const
 
RecordIdType GetAcqFirstRecordId () const
 
TimeTypeGetAcqFirstRecTimes () const
 
RecordIdTypeGetAcqFirstRecordIds () const
 
unsigned GetRecordCountInFile () const
 
unsigned GetNRecordsInFile () const
 
unsigned GetFirstRecordInFile () const
 
bool GetIsInterleaved () const
 
void SetAccessFormat (uint32_t aFormat) const
 Access format can be changed during read or write; must call Initialize() after this. More...
 
uint32_t GetAccessFormat () const
 

Private Types

enum  { N_DATA_DIMS = 2 }
 
typedef void(M3Stream::* DoReadRecordFunc) (bool) const
 
typedef void(M3Stream::* DoWriteRecordFunc) (bool)
 

Private Member Functions

void ReadRecordInterleavedToSeparate (bool aIsNewAcquisition) const
 
void ReadRecordAsIs (bool aIsNewAcquisition) const
 
void WriteRecordSeparateToInterleaved (bool aIsNewAcquisition)
 
void WriteRecordAsIs (bool aIsNewAcquisition)
 
void BuildIndex () const
 
void FinalizeCurrentAcq ()
 
void FinalizeStream ()
 

Private Attributes

DoReadRecordFunc fDoReadRecord
 
DoWriteRecordFunc fDoWriteRecord
 
bool fIsInitialized
 
bool fRecordsAccessed
 
unsigned fDataTypeSize
 
unsigned fSampleSize
 
unsigned fStrRecNBytes
 
unsigned fStrRecSize
 
unsigned fChanRecNBytes
 
unsigned fChanRecSize
 
uint64_t fChanRecLength
 
M3Record fStreamRecord
 
unsigned fNChannels
 
M3RecordfChannelRecords
 
unsigned fNAcquisitions
 
AcquisitionIdType fAcquisitionId
 
unsigned fRecordCountInAcq
 
unsigned fNRecordsInAcq
 
TimeType fAcqFirstRecTime
 
RecordIdType fAcqFirstRecId
 
TimeTypefAcqFirstRecTimes
 
RecordIdTypefAcqFirstRecIds
 
bool fDataInterleaved
 
uint32_t fAccessFormat
 
std::vector< std::pair< unsigned, unsigned > > fRecordIndex
 
unsigned fRecordCountInFile
 
unsigned fNRecordsInFile
 
unsigned fFirstRecordInFile
 
char fAcqNameBuffer [10]
 
H5::Group * fH5StreamParentLoc
 
H5::Group * fH5AcqLoc
 
H5::DataSet * fH5CurrentAcqDataSet
 
H5::DataSpace * fH5DataSpaceUser
 
H5::DataType fDataTypeInFile
 
H5::DataType fDataTypeUser
 
hsize_t fStrDataDims [N_DATA_DIMS]
 
hsize_t fStrMaxDataDims [N_DATA_DIMS]
 
hsize_t fStrDataChunkDims [N_DATA_DIMS]
 
hsize_t fDataDims1Rec [N_DATA_DIMS]
 
hsize_t fDataOffset [N_DATA_DIMS]
 
hsize_t fDataStride [N_DATA_DIMS]
 
hsize_t fDataBlock [N_DATA_DIMS]
 
mutex_ptr fMutexPtr
 

Detailed Description

Read/write access for a data stream.

Author
N. S. Oblath

Data can be read/written either for the stream as a whole, or for individual channels within the stream by accessing the relevant record objects.

The function ReadRecord extracts a record from disk. The offset allows the file to move forward or back within the file. After that call, the new record is available via the record objects.

The function WriteRecord moves the data in memory to disk. Before calling WriteRecord, the appropriate data should be copied to the record object(s).

When a stream object is created, most of the information needed to define the stream characteristics is extracted from the stream header object that is passed to the constructor. Most users won't need to worry about this, as it's already taken care of by the Monarch3 object.

Definition at line 41 of file M3Stream.hh.

Member Typedef Documentation

◆ DoReadRecordFunc

typedef void(M3Stream::* DoReadRecordFunc) (bool) const
private

Definition at line 51 of file M3Stream.hh.

◆ DoWriteRecordFunc

typedef void(M3Stream::* DoWriteRecordFunc) (bool)
private

Definition at line 52 of file M3Stream.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
N_DATA_DIMS 

Definition at line 204 of file M3Stream.hh.

◆ Mode

enum Mode
Enumerator
kRead 
kWrite 

Definition at line 44 of file M3Stream.hh.

Constructor & Destructor Documentation

◆ M3Stream() [1/2]

M3Stream ( const M3StreamHeader aHeader,
HAS_GRP_IFC *  aH5StreamParentLoc,
uint32_t  aAccessFormat = sSeparate 
)

Definition at line 40 of file M3Stream.cc.

◆ ~M3Stream()

~M3Stream ( )
virtual

Definition at line 200 of file M3Stream.cc.

◆ M3Stream() [2/2]

M3Stream ( const M3Stream )
delete

Member Function Documentation

◆ BuildIndex()

void BuildIndex ( ) const
private

Definition at line 615 of file M3Stream.cc.

◆ camel_case_mv_accessible_mutable()

camel_case_mv_accessible_mutable ( Mode  ,
Mode   
)

◆ Close() [1/2]

void Close ( ) const

Close the file.

Definition at line 390 of file M3Stream.cc.

◆ Close() [2/2]

void Close ( )

Close the stream.

Definition at line 473 of file M3Stream.cc.

◆ FinalizeCurrentAcq()

void FinalizeCurrentAcq ( )
private

Definition at line 637 of file M3Stream.cc.

◆ FinalizeStream()

void FinalizeStream ( )
private

Definition at line 653 of file M3Stream.cc.

◆ GetAccessFormat()

uint32_t GetAccessFormat ( ) const
inline

Definition at line 140 of file M3Stream.hh.

◆ GetAcqFirstRecordId()

RecordIdType GetAcqFirstRecordId ( ) const
inline

Definition at line 130 of file M3Stream.hh.

◆ GetAcqFirstRecordIds()

RecordIdType* GetAcqFirstRecordIds ( ) const
inline

Definition at line 132 of file M3Stream.hh.

◆ GetAcqFirstRecordTime()

TimeType GetAcqFirstRecordTime ( ) const
inline

Definition at line 129 of file M3Stream.hh.

◆ GetAcqFirstRecTimes()

TimeType* GetAcqFirstRecTimes ( ) const
inline

Definition at line 131 of file M3Stream.hh.

◆ GetAcquisitionId()

AcquisitionIdType GetAcquisitionId ( ) const
inline

Definition at line 126 of file M3Stream.hh.

◆ GetChannelRecord() [1/2]

const M3Record * GetChannelRecord ( unsigned  aChannel) const

Get the pointer to a particular channel record.

Definition at line 304 of file M3Stream.cc.

◆ GetChannelRecord() [2/2]

M3Record * GetChannelRecord ( unsigned  aChannel)

Get the pointer to a particular channel record.

Definition at line 403 of file M3Stream.cc.

◆ GetChannelRecordNBytes()

unsigned GetChannelRecordNBytes ( ) const
inline

Definition at line 122 of file M3Stream.hh.

◆ GetChannelRecordSize()

unsigned GetChannelRecordSize ( ) const
inline

Definition at line 123 of file M3Stream.hh.

◆ GetDataTypeSize()

unsigned GetDataTypeSize ( ) const
inline

Definition at line 118 of file M3Stream.hh.

◆ GetFirstRecordInFile()

unsigned GetFirstRecordInFile ( ) const
inline

Definition at line 135 of file M3Stream.hh.

◆ GetIsInitialized()

bool GetIsInitialized ( ) const
inline

Definition at line 116 of file M3Stream.hh.

◆ GetIsInterleaved()

bool GetIsInterleaved ( ) const
inline

Definition at line 136 of file M3Stream.hh.

◆ GetNAcquisitions()

unsigned GetNAcquisitions ( ) const
inline

Definition at line 125 of file M3Stream.hh.

◆ GetNChannels()

unsigned GetNChannels ( ) const
inline

Definition at line 124 of file M3Stream.hh.

◆ GetNRecordsInAcquisition()

unsigned GetNRecordsInAcquisition ( ) const
inline

Definition at line 128 of file M3Stream.hh.

◆ GetNRecordsInFile()

unsigned GetNRecordsInFile ( ) const
inline

Definition at line 134 of file M3Stream.hh.

◆ GetRecordCountInAcq()

unsigned GetRecordCountInAcq ( ) const
inline

Definition at line 127 of file M3Stream.hh.

◆ GetRecordCountInFile()

unsigned GetRecordCountInFile ( ) const
inline

Definition at line 133 of file M3Stream.hh.

◆ GetRecordsAccessed()

bool GetRecordsAccessed ( ) const
inline

Definition at line 117 of file M3Stream.hh.

◆ GetSampleSize()

unsigned GetSampleSize ( ) const
inline

Definition at line 119 of file M3Stream.hh.

◆ GetStreamRecord() [1/2]

const M3Record * GetStreamRecord ( ) const

Get the pointer to the stream record.

Definition at line 299 of file M3Stream.cc.

◆ GetStreamRecord() [2/2]

M3Record * GetStreamRecord ( )
inline

Get the pointer to the stream record.

Definition at line 222 of file M3Stream.hh.

◆ GetStreamRecordNBytes()

unsigned GetStreamRecordNBytes ( ) const
inline

Definition at line 120 of file M3Stream.hh.

◆ GetStreamRecordSize()

unsigned GetStreamRecordSize ( ) const
inline

Definition at line 121 of file M3Stream.hh.

◆ Initialize()

void Initialize ( ) const

Setup to read/write data (called in constructor; only call this if read/write parameters change during file reading)

Definition at line 210 of file M3Stream.cc.

◆ operator=()

M3Stream& operator= ( const M3Stream )
delete

◆ ReadRecord()

bool ReadRecord ( int  anOffset = 0,
bool  aIfNewAcqStartAtFirstRec = true 
) const

Read the next record from the file.

Assuming the last record read was [J], ReadRecord will access the [J+1+offset] record. This means that the offset parameter has the following meanings:

  • if offset == 0 (default), the next record will be accessed;
  • if offset == -1, the current record will be reread;
  • offsets < -1 will go backwards in the file;
  • offsets > 0 will skip forward in the file. The flag aIfNewAcqStartAtFirstRec determines the behavior if the read operation moves to a new acquisition. If true, the record read will be the first in the acquisition. If false, the record read will be whatever was stepped to given the offset. Starting at the first record in a new acquisition is behavior that was added (and deemed more useful, and therefore is the default), and this flag provides backwards compatibility.

Definition at line 313 of file M3Stream.cc.

◆ ReadRecordAsIs()

void ReadRecordAsIs ( bool  aIsNewAcquisition) const
private

Definition at line 535 of file M3Stream.cc.

◆ ReadRecordInterleavedToSeparate()

void ReadRecordInterleavedToSeparate ( bool  aIsNewAcquisition) const
private

Definition at line 493 of file M3Stream.cc.

◆ SetAccessFormat()

void SetAccessFormat ( uint32_t  aFormat) const

Access format can be changed during read or write; must call Initialize() after this.

Definition at line 486 of file M3Stream.cc.

◆ SetMutex()

void SetMutex ( const mutex_ptr aMutexPtr)
inline

Definition at line 216 of file M3Stream.hh.

◆ WriteRecord()

bool WriteRecord ( bool  aIsNewAcquisition)

Write the record contents to the file.

Definition at line 412 of file M3Stream.cc.

◆ WriteRecordAsIs()

void WriteRecordAsIs ( bool  aIsNewAcquisition)
private

Definition at line 600 of file M3Stream.cc.

◆ WriteRecordSeparateToInterleaved()

void WriteRecordSeparateToInterleaved ( bool  aIsNewAcquisition)
private

Definition at line 573 of file M3Stream.cc.

Member Data Documentation

◆ fAccessFormat

uint32_t fAccessFormat
mutableprivate

Definition at line 180 of file M3Stream.hh.

◆ fAcqFirstRecId

RecordIdType fAcqFirstRecId
mutableprivate

Definition at line 175 of file M3Stream.hh.

◆ fAcqFirstRecIds

RecordIdType* fAcqFirstRecIds
mutableprivate

Definition at line 177 of file M3Stream.hh.

◆ fAcqFirstRecTime

TimeType fAcqFirstRecTime
mutableprivate

Definition at line 174 of file M3Stream.hh.

◆ fAcqFirstRecTimes

TimeType* fAcqFirstRecTimes
mutableprivate

Definition at line 176 of file M3Stream.hh.

◆ fAcqNameBuffer

char fAcqNameBuffer[10]
mutableprivate

Definition at line 193 of file M3Stream.hh.

◆ fAcquisitionId

AcquisitionIdType fAcquisitionId
mutableprivate

Definition at line 170 of file M3Stream.hh.

◆ fChannelRecords

M3Record* fChannelRecords
mutableprivate

Definition at line 167 of file M3Stream.hh.

◆ fChanRecLength

uint64_t fChanRecLength
mutableprivate

Definition at line 162 of file M3Stream.hh.

◆ fChanRecNBytes

unsigned fChanRecNBytes
mutableprivate

Definition at line 160 of file M3Stream.hh.

◆ fChanRecSize

unsigned fChanRecSize
mutableprivate

Definition at line 161 of file M3Stream.hh.

◆ fDataBlock

hsize_t fDataBlock[N_DATA_DIMS]
mutableprivate

Definition at line 211 of file M3Stream.hh.

◆ fDataDims1Rec

hsize_t fDataDims1Rec[N_DATA_DIMS]
mutableprivate

Definition at line 208 of file M3Stream.hh.

◆ fDataInterleaved

bool fDataInterleaved
mutableprivate

Definition at line 179 of file M3Stream.hh.

◆ fDataOffset

hsize_t fDataOffset[N_DATA_DIMS]
mutableprivate

Definition at line 209 of file M3Stream.hh.

◆ fDataStride

hsize_t fDataStride[N_DATA_DIMS]
mutableprivate

Definition at line 210 of file M3Stream.hh.

◆ fDataTypeInFile

H5::DataType fDataTypeInFile
mutableprivate

Definition at line 201 of file M3Stream.hh.

◆ fDataTypeSize

unsigned fDataTypeSize
mutableprivate

Definition at line 154 of file M3Stream.hh.

◆ fDataTypeUser

H5::DataType fDataTypeUser
mutableprivate

Definition at line 202 of file M3Stream.hh.

◆ fDoReadRecord

DoReadRecordFunc fDoReadRecord
mutableprivate

Definition at line 145 of file M3Stream.hh.

◆ fDoWriteRecord

DoWriteRecordFunc fDoWriteRecord
mutableprivate

Definition at line 149 of file M3Stream.hh.

◆ fFirstRecordInFile

unsigned fFirstRecordInFile
mutableprivate

Definition at line 185 of file M3Stream.hh.

◆ fH5AcqLoc

H5::Group* fH5AcqLoc
mutableprivate

Definition at line 196 of file M3Stream.hh.

◆ fH5CurrentAcqDataSet

H5::DataSet* fH5CurrentAcqDataSet
mutableprivate

Definition at line 197 of file M3Stream.hh.

◆ fH5DataSpaceUser

H5::DataSpace* fH5DataSpaceUser
mutableprivate

Definition at line 199 of file M3Stream.hh.

◆ fH5StreamParentLoc

H5::Group* fH5StreamParentLoc
mutableprivate

Definition at line 195 of file M3Stream.hh.

◆ fIsInitialized

bool fIsInitialized
mutableprivate

Definition at line 151 of file M3Stream.hh.

◆ fMutexPtr

mutex_ptr fMutexPtr
mutableprivate

Definition at line 213 of file M3Stream.hh.

◆ fNAcquisitions

unsigned fNAcquisitions
mutableprivate

Definition at line 169 of file M3Stream.hh.

◆ fNChannels

unsigned fNChannels
mutableprivate

Definition at line 166 of file M3Stream.hh.

◆ fNRecordsInAcq

unsigned fNRecordsInAcq
mutableprivate

Definition at line 173 of file M3Stream.hh.

◆ fNRecordsInFile

unsigned fNRecordsInFile
mutableprivate

Definition at line 184 of file M3Stream.hh.

◆ fRecordCountInAcq

unsigned fRecordCountInAcq
mutableprivate

Definition at line 172 of file M3Stream.hh.

◆ fRecordCountInFile

unsigned fRecordCountInFile
mutableprivate

Definition at line 183 of file M3Stream.hh.

◆ fRecordIndex

std::vector< std::pair< unsigned, unsigned > > fRecordIndex
mutableprivate

Definition at line 182 of file M3Stream.hh.

◆ fRecordsAccessed

bool fRecordsAccessed
mutableprivate

Definition at line 152 of file M3Stream.hh.

◆ fSampleSize

unsigned fSampleSize
mutableprivate

Definition at line 155 of file M3Stream.hh.

◆ fStrDataChunkDims

hsize_t fStrDataChunkDims[N_DATA_DIMS]
mutableprivate

Definition at line 207 of file M3Stream.hh.

◆ fStrDataDims

hsize_t fStrDataDims[N_DATA_DIMS]
mutableprivate

Definition at line 205 of file M3Stream.hh.

◆ fStreamRecord

M3Record fStreamRecord
mutableprivate

Definition at line 164 of file M3Stream.hh.

◆ fStrMaxDataDims

hsize_t fStrMaxDataDims[N_DATA_DIMS]
mutableprivate

Definition at line 206 of file M3Stream.hh.

◆ fStrRecNBytes

unsigned fStrRecNBytes
mutableprivate

Definition at line 157 of file M3Stream.hh.

◆ fStrRecSize

unsigned fStrRecSize
mutableprivate

Definition at line 158 of file M3Stream.hh.


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