nidas  v1.2-1520
Public Types | Public Member Functions | Public Attributes | List of all members
nidas::dynld::BlockStats Struct Reference

Keep track of statistics for a contiguous block of good or bad samples in a stream. More...

#include <SampleInputStream.h>

Public Types

typedef nidas::core::dsm_time_t dsm_time_t
 

Public Member Functions

 BlockStats (bool goodblock=true, size_t startblock=0)
 Initialize a block as good or bad and give it an offset. More...
 
bool addGoodSample (nidas::core::Sample *samp, long long offset)
 On a good sample, reset this block to a good block if not already, and update the last good sample and the size of the block. More...
 
void addBadSample (long long offset, unsigned int nbadbytes)
 An alternative to calling startBadBlock()/endBadBlock(), it adds nbadbytes to a bad block, resetting the block from good to bad if necessary. More...
 
void startBadBlock (long long offset)
 Start a bad block. More...
 
void endBadBlock (nidas::core::Sample *samp, long long offset)
 Mark the end of a bad block by assigning the end_time and setting nbytes according to the current offset. More...
 
size_t blockEnd () const
 

Public Attributes

dsm_time_t start_time
 Sample times bounding this block. More...
 
dsm_time_t end_time
 
bool good
 True if this is a block of good samples. More...
 
size_t nsamples
 Number of good samples in a row. More...
 
size_t block_start
 
size_t nbytes
 Size in bytes of this block. More...
 
unsigned int last_good_sample_size
 Size of the last good sample in a good sample block. More...
 

Detailed Description

Keep track of statistics for a contiguous block of good or bad samples in a stream.

Member Typedef Documentation

Constructor & Destructor Documentation

BlockStats::BlockStats ( bool  goodblock = true,
size_t  startblock = 0 
)

Initialize a block as good or bad and give it an offset.

Blocks default to being good but empty.

Referenced by addGoodSample(), and startBadBlock().

Member Function Documentation

void BlockStats::addBadSample ( long long  offset,
unsigned int  nbadbytes 
)

An alternative to calling startBadBlock()/endBadBlock(), it adds nbadbytes to a bad block, resetting the block from good to bad if necessary.

It is analogous to the addGoodSample() method. Use startBadBlock() and endBadBlock() to avoid calling addGoodSample() on every single bad byte. When a bad block is started from a good block, it copies the end_time from the good block into the start_time of the new bad block.

References good, nbytes, and startBadBlock().

bool BlockStats::addGoodSample ( nidas::core::Sample samp,
long long  offset 
)

On a good sample, reset this block to a good block if not already, and update the last good sample and the size of the block.

Call this method on each good sample so that when a bad header appears, all the stats in this block are already correct. Return true if this is the start of a new good block.

References BlockStats(), end_time, nidas::core::Sample::getDataByteLength(), nidas::core::Sample::getHeaderLength(), nidas::core::Sample::getTimeTag(), good, last_good_sample_size, nbytes, nsamples, and start_time.

Referenced by nidas::dynld::SampleInputStream::sampleFromHeader().

size_t nidas::dynld::BlockStats::blockEnd ( ) const
inline

References block_start, and nbytes.

Referenced by operator<<().

void BlockStats::endBadBlock ( nidas::core::Sample samp,
long long  offset 
)

Mark the end of a bad block by assigning the end_time and setting nbytes according to the current offset.

If the block ends without a good sample, then pass samp as NULL, in which case the end_time will remain at the default of LONG_LONG_MAX.

References block_start, end_time, nidas::core::Sample::getTimeTag(), and nbytes.

Referenced by nidas::dynld::SampleInputStream::sampleFromHeader().

void BlockStats::startBadBlock ( long long  offset)

Start a bad block.

The size (nbytes) will not be correct until endBadBlock() is called.

References BlockStats(), end_time, nbytes, and start_time.

Referenced by addBadSample(), and nidas::dynld::SampleInputStream::sampleFromHeader().

Member Data Documentation

size_t nidas::dynld::BlockStats::block_start
dsm_time_t nidas::dynld::BlockStats::end_time
bool nidas::dynld::BlockStats::good

True if this is a block of good samples.

Referenced by addBadSample(), addGoodSample(), operator<<(), and nidas::dynld::SampleInputStream::sampleFromHeader().

unsigned int nidas::dynld::BlockStats::last_good_sample_size

Size of the last good sample in a good sample block.

It is zero in a bad block.

Referenced by addGoodSample(), and operator<<().

size_t nidas::dynld::BlockStats::nbytes
size_t nidas::dynld::BlockStats::nsamples

Number of good samples in a row.

Zero in a bad block.

Referenced by addGoodSample(), and operator<<().

dsm_time_t nidas::dynld::BlockStats::start_time

Sample times bounding this block.

For good blocks, these are the sample times for the first and last samples in the block. For bad blocks, they are the sample times of the last good sample before the block and the first good sample after the block. If unset, start_time is LONG_LONG_MIN and end_time is LONG_LONG_MAX.

Referenced by addGoodSample(), operator<<(), nidas::dynld::SampleInputStream::sampleFromHeader(), and startBadBlock().


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