nidas v1.2.3
|
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. | |
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. | |
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. | |
void | startBadBlock (long long offset) |
Start a bad block. | |
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. | |
size_t | blockEnd () const |
Public Attributes | |
dsm_time_t | start_time |
Sample times bounding this block. | |
dsm_time_t | end_time |
bool | good |
True if this is a block of good samples. | |
size_t | nsamples |
Number of good samples in a row. | |
size_t | block_start |
size_t | nbytes |
Size in bytes of this block. | |
unsigned int | last_good_sample_size |
Size of the last good sample in a good sample block. | |
Keep track of statistics for a contiguous block of good or bad samples in a stream.
Initialize a block as good or bad and give it an offset.
Blocks default to being good but empty.
Referenced by addGoodSample(), and startBadBlock().
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::getSample(), good, last_good_sample_size, nbytes, nsamples, and start_time.
Referenced by nidas::dynld::SampleInputStream::sampleFromHeader().
|
inline |
References block_start, and nbytes.
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, and nbytes.
Referenced by nidas::dynld::SampleInputStream::sampleFromHeader().
Start a bad block.
The size (nbytes) will not be correct until endBadBlock() is called.
References BlockStats(), end_time, nidas::core::getSample(), nbytes, and start_time.
Referenced by addBadSample(), and nidas::dynld::SampleInputStream::sampleFromHeader().
size_t nidas::dynld::BlockStats::block_start |
Referenced by blockEnd(), nidas::dynld::SampleInputStream::closeBlocks(), and endBadBlock().
dsm_time_t nidas::dynld::BlockStats::end_time |
Referenced by addGoodSample(), endBadBlock(), and startBadBlock().
bool nidas::dynld::BlockStats::good |
True if this is a block of good samples.
Referenced by addBadSample(), addGoodSample(), and nidas::dynld::SampleInputStream::sampleFromHeader().
Size of the last good sample in a good sample block.
It is zero in a bad block.
Referenced by addGoodSample().
size_t nidas::dynld::BlockStats::nbytes |
Size in bytes of this block.
Starts out empty at zero.
Referenced by addBadSample(), addGoodSample(), blockEnd(), nidas::dynld::SampleInputStream::closeBlocks(), endBadBlock(), nidas::dynld::SampleInputStream::sampleFromHeader(), and startBadBlock().
size_t nidas::dynld::BlockStats::nsamples |
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(), nidas::dynld::SampleInputStream::sampleFromHeader(), and startBadBlock().