Brief description of class still missing. More...
#include <MiniSeedReader.h>
Public Types | |
enum | Type { Text, Integer, Float, Double } |
Public Member Functions | |
bool | atEnd () const |
off_t | lastPos () const |
MiniSeedReader (QString fileName, const MiniSeedRecords *records) | |
void * | nextRecord (Type &t, int &nSamples) |
~MiniSeedReader () |
Brief description of class still missing.
Used by Signal to load samples with the help of a record list stored in MiniSeedRecords.
GeopsyCore::MiniSeedReader::MiniSeedReader | ( | QString | fileName, |
const MiniSeedRecords * | records | ||
) |
bool GeopsyCore::MiniSeedReader::atEnd | ( | ) | const |
References GeopsyCore::MiniSeedRecords::recordCount(), and GeopsyCore::MiniSeedRecords::sequenceCount().
{ if(_sequenceIndex>=_records->sequenceCount()) { return true; } return _recordIndex>=_records->recordCount(_sequenceIndex); }
off_t GeopsyCore::MiniSeedReader::lastPos | ( | ) | const |
References GeopsyCore::MiniSeedRecords::record(), and SAFE_UNINITIALIZED.
{ off_t pos; quint32 recLen; SAFE_UNINITIALIZED(pos, 0); SAFE_UNINITIALIZED(recLen, 0); _records->record(_sequenceIndex, _recordIndex, pos, recLen); return pos; }
void * GeopsyCore::MiniSeedReader::nextRecord | ( | Type & | t, |
int & | nSamples | ||
) |
Returns the samples contained in next record with type t. nSamples is set to the number of samples.
References Double, QGpCoreTools::endl(), GeopsyCore::MiniSeedVolume::errorLog(), Float, Integer, GeopsyCore::MiniSeedRecords::record(), SAFE_UNINITIALIZED, GeopsyCore::MiniSeedRecords::sequenceCount(), Text, QGpCoreTools::tr(), and TRACE.
{ TRACE; if(!_f) { App::stream() << tr("File not open") << endl; return 0; } off_t pos; quint32 recLen; SAFE_UNINITIALIZED(pos, 0); SAFE_UNINITIALIZED(recLen, 0); if(!_records->record(_sequenceIndex, ++_recordIndex, pos, recLen)) { _sequenceIndex++; _recordIndex=0; if(_sequenceIndex>=_records->sequenceCount()) { return 0; } if(!_records->record(_sequenceIndex, _recordIndex, pos, recLen)) { App::stream() << tr("Corrupted record, count=0") << endl; return 0; } } _f->seek(pos); char buf[recLen]; if(_f->read(buf, recLen)<recLen) { App::stream() << tr("Record not completely read") << endl; return 0; } if(!MS_ISVALIDHEADER(buf)) { App::stream() << tr("Not a valid seed record") << endl; return 0; } int msErr=msr_unpack (buf, recLen, &_msr, 1, 0); if(msErr!= MS_NOERROR) { MiniSeedVolume::errorLog(_f->fileName(), tr("Loading Miniseed values"), msErr); return false; } nSamples=_msr->samplecnt; switch(_msr->sampletype) { case 'i': t=Integer; break; case 'f': t=Float; break; case 'd': t=Double; break; default: t=Text; break; } return _msr->datasamples; }