pappso::TimsBinDec Class Reference

`#include <timsbindec.h>`

## Public Member Functions

| TimsBinDec (const QFileInfo &timsBinFile, int timsCompressionType)
| TimsBinDec (const TimsBinDec &other)
| ~TimsBinDec ()
TimsFrameSPtr | getTimsFrameSPtrByOffset (std::size_t timsId, std::size_t timsOffset)

## Private Member Functions

void | indexingFile ()

## Private Attributes

int | m_timsCompressionType
QString | m_timsBinFile
char * | mpa_memoryBuffer = nullptr
qint64 | m_memoryBufferSize = 0
char * | mpa_decompressMemoryBuffer = nullptr
std::size_t | m_decompressMemoryBufferSize = 0

## Detailed Description

Todo:
  write docs

Definition at line 40 of file timsbindec.h.

## Constructor & Destructor Documentation

## TimsBinDec() [1/2]

TimsBinDec::TimsBinDec | ( | const QFileInfo & | timsBinFile,
|  | int | timsCompressionType
| ) |  |

Default constructor

Definition at line 37 of file timsbindec.cpp.

: m_timsBinFile(timsBinFile.absoluteFilePath())
{
m_timsCompressionType = timsCompressionType;
if((timsCompressionType != 1) && (timsCompressionType != 2))
{
throw pappso::ExceptionNotImplemented(
QObject::tr("compression type %1 not handled by this library")
.arg(timsCompressionType));
}
if(m_timsBinFile.isEmpty())
{
throw pappso::PappsoException(
QObject::tr("No TIMS binary file name specified"));
}
QFile file(m_timsBinFile);
if(!file.open(QIODevice::ReadOnly))
{
throw PappsoException(
QObject::tr("ERROR opening TIMS binary file %1 for read")
.arg(timsBinFile.absoluteFilePath()));
}
}
pappso::ExceptionNotImplemented
Definition: exceptionnotimplemented.h:32
pappso::PappsoException
Definition: pappsoexception.h:42
pappso::TimsBinDec::m_timsCompressionType
int m_timsCompressionType
Definition: timsbindec.h:69
pappso::TimsBinDec::m_timsBinFile
QString m_timsBinFile
Definition: timsbindec.h:70

References m_timsBinFile, and m_timsCompressionType.

## TimsBinDec() [2/2]

TimsBinDec::TimsBinDec | ( | const TimsBinDec & | other | ) |

Copy constructor

Parameters

  other | TODO

Definition at line 62 of file timsbindec.cpp.

: m_timsBinFile(other.m_timsBinFile)
{
}

## ~TimsBinDec()

TimsBinDec::~TimsBinDec | ( |  | ) |

Destructor

Definition at line 67 of file timsbindec.cpp.

{
if(mpa_memoryBuffer != nullptr)
{
delete[] mpa_memoryBuffer;
mpa_memoryBuffer = nullptr;
}
if(mpa_decompressMemoryBuffer != nullptr)
{
delete[] mpa_decompressMemoryBuffer;
}
}
pappso::TimsBinDec::mpa_memoryBuffer
char * mpa_memoryBuffer
Definition: timsbindec.h:72
pappso::TimsBinDec::mpa_decompressMemoryBuffer
char * mpa_decompressMemoryBuffer
Definition: timsbindec.h:76

References mpa_decompressMemoryBuffer, and mpa_memoryBuffer.

## Member Function Documentation

## getTimsFrameSPtrByOffset()

TimsFrameSPtr TimsBinDec::getTimsFrameSPtrByOffset | ( | std::size_t | timsId,
|  | std::size_t | timsOffset
| ) |  |

Definition at line 155 of file timsbindec.cpp.

{
qDebug() << "timsId:" << timsId << "timsOffset:" << timsOffset;
// QMutexLocker locker(&m_mutex);
QFile file(m_timsBinFile);
if(!file.open(QIODevice::ReadOnly))
{
throw PappsoException(
QObject::tr("ERROR opening TIMS binary file %1 for read")
.arg(m_timsBinFile));
}
qDebug();
bool seekpos_ok = file.seek(timsOffset);
if(!seekpos_ok)
{
throw PappsoException(
QObject::tr("ERROR reading TIMS frame %1 TIMS binary file %2: "
"m_timsBinFile.seek(%3) failed")
.arg(timsId)
.arg(m_timsBinFile)
.arg(timsOffset));
}
qDebug();
quint32 frame_length;
file.read((char *)&frame_length, 4);
// frame_length = qToBigEndian(frame_length);
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
// << " frame_length=" << frame_length;
qDebug();
quint32 scan_number;
file.read((char *)&scan_number, 4);
// scan_number = qToBigEndian(scan_number);
frame_length -= 8;
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
// << " pos=" << m_timsBinFile.pos();
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
// << " scan_number=" << scan_number;
// m_timsBinFile.seek(m_indexArray.at(timsId) + 8);
qDebug();
// if (m_memoryBufferSize
if(mpa_memoryBuffer == nullptr)
{
qDebug() << "mpa_memoryBuffer == nullptr";
m_memoryBufferSize = (qint64)frame_length + 10;
mpa_memoryBuffer = new char[m_memoryBufferSize];
}
if((m_memoryBufferSize - 10) < frame_length)
{
if(mpa_memoryBuffer != nullptr)
{
delete[] mpa_memoryBuffer;
}
m_memoryBufferSize = (qint64)frame_length + 10;
mpa_memoryBuffer = new char[m_memoryBufferSize];
}
// QByteArray frame_byte_array(mpa_memoryBuffer, m_memoryBufferSize);
qDebug();
qint64 read_length = file.read(mpa_memoryBuffer, (qint64)frame_length + 2);
qDebug();
file.close();
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
// << " +frame_length-1="
// << (quint8) * (frame_byte_array.constData() + frame_length - 1);
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
// << " +frame_length="
// << (quint8) * (frame_byte_array.constData() + frame_length);
// m_timsBinFile.seek(m_indexArray.at(timsId) + 8);
if(read_length - 2 != (qint64)frame_length)
{
throw PappsoException(
QObject::tr("ERROR reading TIMS frame %1 TIMS binary file %2: "
"read_length=%3 != %4frame_length")
.arg(timsId)
.arg(m_timsBinFile)
.arg(read_length)
.arg(frame_length));
}
qDebug();
TimsFrameSPtr frame_sptr;
if(frame_length > 0)
{
qDebug();
if(m_timsCompressionType == 2)
{
auto decompressed_size2 =
ZSTD_getFrameContentSize(mpa_memoryBuffer, frame_length);
qDebug();
if(decompressed_size2 == ZSTD_CONTENTSIZE_UNKNOWN)
{
throw PappsoException(
QObject::tr("ERROR reading TIMS frame %1 TIMS binary file %2: "
" decompressed_size2 == ZSTD_CONTENTSIZE_UNKNOWN, "
"frame_length=%3")
.arg(timsId)
.arg(m_timsBinFile)
.arg(frame_length));
}
qDebug();
if(decompressed_size2 == ZSTD_CONTENTSIZE_ERROR)
{
qDebug();
throw PappsoException(
QObject::tr("ERROR reading TIMS frame %1 TIMS binary file %2: "
" decompressed_size2 == ZSTD_CONTENTSIZE_ERROR, "
"frame_length=%3")
.arg(timsId)
.arg(m_timsBinFile)
.arg(frame_length));
}
qDebug() << " decompressed_size2=" << decompressed_size2;
if(m_decompressMemoryBufferSize < (decompressed_size2 + 10))
{
if(mpa_decompressMemoryBuffer != nullptr)
{
delete[] mpa_decompressMemoryBuffer;
}
m_decompressMemoryBufferSize = decompressed_size2 + 10;
mpa_decompressMemoryBuffer =
new char[m_decompressMemoryBufferSize];
}
std::size_t decompressed_size =
ZSTD_decompress(mpa_decompressMemoryBuffer,
m_decompressMemoryBufferSize,
mpa_memoryBuffer,
frame_length);
qDebug();
if(decompressed_size != decompressed_size2)
{
throw PappsoException(
QObject::tr("ERROR reading TIMS frame %1 TIMS binary file %2: "
"decompressed_size != decompressed_size2")
.arg(timsId)
.arg(m_timsBinFile)
.arg(decompressed_size)
.arg(decompressed_size2));
}
qDebug();
frame_sptr = std::make_shared<TimsFrame>(
timsId, scan_number, mpa_decompressMemoryBuffer, decompressed_size);
}
else
{
if(m_timsCompressionType == 1)
{
frame_sptr = std::make_shared<TimsFrameType1>(
timsId, scan_number, mpa_memoryBuffer, frame_length);
}
}
// delete[] mpa_decompressMemoryBuffer;
}
else
{
frame_sptr = std::make_shared<TimsFrame>(timsId, scan_number, nullptr, 0);
}
return frame_sptr;
}
pappso::TimsBinDec::m_decompressMemoryBufferSize
std::size_t m_decompressMemoryBufferSize
Definition: timsbindec.h:77
pappso::TimsBinDec::m_memoryBufferSize
qint64 m_memoryBufferSize
Definition: timsbindec.h:73
pappso::TimsFrameSPtr
std::shared_ptr< TimsFrame > TimsFrameSPtr
Definition: timsframe.h:41

References m_decompressMemoryBufferSize, m_memoryBufferSize, m_timsBinFile, m_timsCompressionType, mpa_decompressMemoryBuffer, and mpa_memoryBuffer.

Referenced by pappso::TimsData::getTimsFrameCstSPtr().

## indexingFile()

void TimsBinDec::indexingFile | ( |  | ) |

private

Definition at line 84 of file timsbindec.cpp.

{
qDebug();
QFile file(m_timsBinFile);
QDataStream bin_in(&file);
bin_in.setByteOrder(QDataStream::ByteOrder::LittleEndian);
// m_indexArray.push_back(0);
// QChar first_char;
// txt_in >> first_char;
quint32 number_in;
qint64 position(0);
qint8 trash;
while(!bin_in.atEnd())
{
while((!bin_in.atEnd()) && (position % 4 != 0))
{
bin_in >> trash;
position += 1;
if(trash != 0)
{ /*
throw PappsoException(
QObject::tr("ERROR reading TIMS frame %1 TIMS binary file %2: "
"trash%3 != 0")
.arg(m_indexArray.size())
.arg(m_timsBinFile.fileName())
.arg(trash));*/
}
}
quint32 frame_len(0);
while((!bin_in.atEnd()) && (frame_len == 0))
{
bin_in >> frame_len;
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
// << " i=" << i;
position += 4;
}
// m_indexArray.push_back(position - 4);
/*
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
<< " frame_len=" << frame_len
<< " frameid=" << m_indexArray.size() - 1
<< " back=" << m_indexArray.back() << " position=" <<
position;
quint64 next_frame = m_indexArray.back() + frame_len;
*/
bin_in >> number_in;
position += 4;
qDebug() << " number_in(nb scans)=" << number_in
<< " position=" << position;
;
/*
while((!bin_in.atEnd()) && (position < next_frame))
{
bin_in >> trash;
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " <<
__LINE__
// << " i=" << i;
position += 1;
}*/
}
qDebug();
}

References m_timsBinFile.

## Member Data Documentation

## m_decompressMemoryBufferSize

std::size_t pappso::TimsBinDec::m_decompressMemoryBufferSize = 0

private

Definition at line 77 of file timsbindec.h.

Referenced by getTimsFrameSPtrByOffset().

## m_memoryBufferSize

qint64 pappso::TimsBinDec::m_memoryBufferSize = 0

private

Definition at line 73 of file timsbindec.h.

Referenced by getTimsFrameSPtrByOffset().

## m_timsBinFile

QString pappso::TimsBinDec::m_timsBinFile

private

Definition at line 70 of file timsbindec.h.

Referenced by TimsBinDec(), getTimsFrameSPtrByOffset(), and indexingFile().

## m_timsCompressionType

int pappso::TimsBinDec::m_timsCompressionType

private

Definition at line 69 of file timsbindec.h.

Referenced by TimsBinDec(), and getTimsFrameSPtrByOffset().

## mpa_decompressMemoryBuffer

char* pappso::TimsBinDec::mpa_decompressMemoryBuffer = nullptr

private

Definition at line 76 of file timsbindec.h.

Referenced by ~TimsBinDec(), and getTimsFrameSPtrByOffset().

## mpa_memoryBuffer

char* pappso::TimsBinDec::mpa_memoryBuffer = nullptr

private

Definition at line 72 of file timsbindec.h.

Referenced by ~TimsBinDec(), and getTimsFrameSPtrByOffset().

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

- pappsomspp/vendors/tims/timsbindec.h
- pappsomspp/vendors/tims/timsbindec.cpp