lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
XtcData::XtcFileIterator Class Reference

Reads datagrams sequentially from a file descriptor into a single internal buffer of maxDgramSize bytes. More...

#include <XtcFileIterator.hh>

Public Member Functions

 XtcFileIterator (int fd, size_t maxDgramSize)
 Store fd and allocate the internal buffer of maxDgramSize bytes.
 
 ~XtcFileIterator ()
 Free the internal buffer; fd is not closed.
 
Dgram * next ()
 Read the next Dgram header (sizeof(Dgram) bytes) and then its xtc payload into the internal buffer.
 
void rewind ()
 Seek fd back to offset 0 with lseek(); the result is not checked.
 
size_t size () const
 Return the buffer size maxDgramSize given to the constructor.
 

Detailed Description

Reads datagrams sequentially from a file descriptor into a single internal buffer of maxDgramSize bytes.

Constructor & Destructor Documentation

◆ XtcFileIterator()

XtcData::XtcFileIterator::XtcFileIterator ( int  fd,
size_t  maxDgramSize 
)

Store fd and allocate the internal buffer of maxDgramSize bytes.

The file descriptor is not opened or closed by this class.

◆ ~XtcFileIterator()

XtcData::XtcFileIterator::~XtcFileIterator ( )

Free the internal buffer; fd is not closed.

Member Function Documentation

◆ next()

Dgram * XtcData::XtcFileIterator::next ( )

Read the next Dgram header (sizeof(Dgram) bytes) and then its xtc payload into the internal buffer.

Only a header read returning 0 is treated as end of file; failed or short header reads are not checked.

Returns
Pointer to the Dgram in the internal buffer (overwritten by the next call), or 0 at end of file, if header plus payload exceed maxDgramSize, or if the payload read fails or ends early (these last cases print a message).

◆ rewind()

void XtcData::XtcFileIterator::rewind ( )

Seek fd back to offset 0 with lseek(); the result is not checked.

◆ size()

size_t XtcData::XtcFileIterator::size ( ) const
inline

Return the buffer size maxDgramSize given to the constructor.


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