All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Types | Public Member Functions
GeopsyCore::MiniSeedReader Class Reference

Brief description of class still missing. More...

#include <MiniSeedReader.h>

List of all members.

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 ()

Detailed Description

Brief description of class still missing.

Used by Signal to load samples with the help of a record list stored in MiniSeedRecords.


Member Enumeration Documentation

Enumerator:
Text 
Integer 
Float 
Double 

Constructor & Destructor Documentation

GeopsyCore::MiniSeedReader::MiniSeedReader ( QString  fileName,
const MiniSeedRecords records 
)

Description of constructor still missing

References TRACE.

{
  TRACE;
  _records=records;
  _sequenceIndex=0;
  _recordIndex=-1;

  _f=new QFile(fileName);
  if(!_f->open(QIODevice::ReadOnly)) {
    delete _f;
    _f=0;
  }
  _msr=0;
}

Description of destructor still missing

References TRACE.

{
  TRACE;
  delete _f;
}

Member Function Documentation

References GeopsyCore::MiniSeedRecords::recordCount(), and GeopsyCore::MiniSeedRecords::sequenceCount().

{
  if(_sequenceIndex>=_records->sequenceCount()) {
    return true;
  }
  return _recordIndex>=_records->recordCount(_sequenceIndex);
}

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;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines