57 lCode_ = lCode.leftJustified(8,
' ',
true);
111 descriptorByLCode_(),
112 listOfDataBlocksToc0_(),
113 listOfObservations_(),
114 listOfNewDescriptors_(),
115 listOfDeletedDescriptors_(),
253 if (descriptor->
nTc()==0)
257 QString().sprintf(
": properRecord(): obsNum %d is greater or equal 0 for TOC#0",
266 QString().sprintf(
": properRecord(): obsNum %d is less than 0",
273 QString().sprintf(
": properRecord(): obsNum %d >= listOfObservations_.size(), %d",
282 QString().sprintf(
": properRecord(): Observation entry is NULL for obsNum %d",
287 if (!listOfDataBlocks)
290 QString().sprintf(
": properRecord(): listOfDataBlocks is NULL for obsNum %d and TOC#%d",
291 obsNum, descriptor->
nTc()));
294 dataBlock = listOfDataBlocks->at(descriptor->
nTe());
300 QString().sprintf(
": properRecord(): Data Block is NULL for obsNum %d TOC#%d TE#%d",
301 obsNum, descriptor->
nTc(), descriptor->
nTe()));
304 QHash<int, SgDbhPhysicalRecord*> *recByType = dataBlock->
recordByType();
305 if (!recByType->contains(descriptor->
type()))
308 QString().sprintf(
": properRecord(): recordByType_ hash (TOC#%d, TE#%d) does not contain"
309 "the record of type %d", descriptor->
nTc(), descriptor->
nTe(), descriptor->
type()));
312 return recByType->value(descriptor->
type());
323 ": getStr(): descriptor is NULL");
324 return QString(
"UNDEF");
338 ": getData(): the " + typeName +
" descriptor is NULL");
349 return getData<double>(
"double:R8", d, i,j,k, obsNumber);
357 return getData<double>(
"double:D8", d, i,j,k, obsNumber);
365 return getData<int>(
"int:J4", d, i,j,k, obsNumber);
373 return getData<short>(
"short:I2", d, i,j,k, obsNumber);
386 ": setStr(): descriptor is NULL");
395 ": setStr(): the image is in inconsistent state");
409 ": setData(): descriptor is NULL");
418 ": setData(): the image is in inconsistent state");
426 return setData<double>(d, i,j,k, obsNumber, r8);
434 return setData<double>(d, i,j,k, obsNumber, d8);
442 return setData<int>(d, i,j,k, obsNumber, j4);
450 return setData<short>(d, i,j,k, obsNumber, i2);
462 QString().sprintf(
": copyToc0Content(): Wrong order of calling, current TOC is TOC#%d",
470 for (
int teCount=0; teCount<tcBlock0->
listOfTeBlocks()->size(); teCount++)
491 QString(
"").sprintf(
": copyToc0Content(): the TOC#0 already contains the parameter [%s]",
492 qPrintable(descriptor->
getLCode())));
494 if (descriptor->
getLCode()!=
"R-FILLER" &&
495 descriptor->
getLCode()!=
"I-FILLER" &&
496 descriptor->
getLCode()!=
"A-FILLER" &&
497 descriptor->
getLCode()!=
"D-FILLER" &&
552 for (
int teIdx=0; teIdx<tcBlock->
listOfTeBlocks()->size(); teIdx++)
576 QString().sprintf(
": finisFormatModifying(): deleted %d descriptors",
591 while (i < teBlock->listOfDescriptors()->size() &&
595 while (i < teBlock->listOfDescriptors()->size() &&
607 QString().sprintf(
": finisFormatModifying(): added %d descriptors",
614 for (
int teIdx=0; teIdx<tcBlock->
listOfTeBlocks()->size(); teIdx++)
631 ": finisFormatModifying(): data records are adjusted");
640 int offset=0, sizeOfType=0, recordLength=0;
646 for (
int teIdx=0; teIdx<listOfDataBlocks->size(); teIdx++)
648 dataBlock = listOfDataBlocks->at(teIdx);
654 for (
int i=0; i<listOfDescriptors->size(); i++)
657 if (descriptor->
getLCode()==
"R-FILLER")
660 sizeOfType =
sizeof(double);
662 recordLength = sizeOfType*teBlock->
recTe().
r8Num();
664 newRecord->
reSize(recordLength);
665 newDataBlock->listOfRecords()->append(newRecord);
666 newDataBlock->recordByType()->insert(recordType, newRecord);
667 oldRecord = dataBlock->
recordByType()->value(recordType);
669 else if (descriptor->
getLCode()==
"I-FILLER")
672 sizeOfType =
sizeof(short);
674 recordLength = sizeOfType*teBlock->
recTe().
i2Num();
676 newRecord->
reSize(recordLength);
677 newDataBlock->listOfRecords()->append(newRecord);
678 newDataBlock->recordByType()->insert(recordType, newRecord);
679 oldRecord = dataBlock->
recordByType()->value(recordType);
681 else if (descriptor->
getLCode()==
"A-FILLER")
684 sizeOfType = 2*
sizeof(char);
686 recordLength = sizeOfType*teBlock->
recTe().
a2Num();
688 newRecord->
reSize(recordLength);
689 newDataBlock->listOfRecords()->append(newRecord);
690 newDataBlock->recordByType()->insert(recordType, newRecord);
691 oldRecord = dataBlock->
recordByType()->value(recordType);
693 else if (descriptor->
getLCode()==
"D-FILLER")
696 sizeOfType =
sizeof(double);
698 recordLength = sizeOfType*teBlock->
recTe().
d8Num();
700 newRecord->
reSize(recordLength);
701 newDataBlock->listOfRecords()->append(newRecord);
702 newDataBlock->recordByType()->insert(recordType, newRecord);
703 oldRecord = dataBlock->
recordByType()->value(recordType);
705 else if (descriptor->
getLCode()==
"J-FILLER")
708 sizeOfType =
sizeof(int);
710 recordLength = sizeOfType*teBlock->
recTe().
j4Num();
712 newRecord->
reSize(recordLength);
713 newDataBlock->listOfRecords()->append(newRecord);
714 newDataBlock->recordByType()->insert(recordType, newRecord);
715 oldRecord = dataBlock->
recordByType()->value(recordType);
718 if (descriptor->
offset()>-1)
719 memcpy(newRecord->
base() + sizeOfType*offset,
720 oldRecord->base() + sizeOfType*descriptor->
offset(),
721 sizeOfType*descriptor->
dim1()*descriptor->
dim2()*descriptor->
dim3());
722 offset += descriptor->
dim1()*descriptor->
dim2()*descriptor->
dim3();
729 for (
int i=0; i<newDataBlock->listOfRecords()->size(); i++)
730 dataBlock->
listOfRecords()->append(newDataBlock->listOfRecords()->at(i));
731 QHash<int, SgDbhPhysicalRecord*>::const_iterator j;
732 for (j=newDataBlock->recordByType()->constBegin();
733 j!=newDataBlock->recordByType()->constEnd(); ++j)
736 newDataBlock->recordByType()->clear();
737 newDataBlock->listOfRecords()->clear();
755 for (
int teIdx=0; teIdx<tcBlock->
listOfTeBlocks()->size(); teIdx++)
759 for (
int i=0; i<listOfDescriptors->size(); i++)
762 if (descriptor->
getLCode()==
"R-FILLER")
764 else if (descriptor->
getLCode()==
"I-FILLER")
766 else if (descriptor->
getLCode()==
"A-FILLER")
768 else if (descriptor->
getLCode()==
"D-FILLER")
770 else if (descriptor->
getLCode()==
"J-FILLER")
773 offset += descriptor->
dim1()*descriptor->
dim2()*descriptor->
dim3();
785 int numOfWrittenPhysRecords = 0;
795 numOfWrittenPhysRecords++;
796 for (
int teIdx=0; teIdx<listOfDBlocks->size(); teIdx++)
808 numOfWrittenPhysRecords++;
812 numOfWrittenPhysRecords++;
829 ": addDescriptor(): called when the image is not in proper state");
835 ": addDescriptor(): descriptor is NULL");
846 QString().sprintf(
": addDescriptor(): the descriptor [%s] is already in the list",
854 QString().sprintf(
": addDescriptor(): the descriptor [%s] has unknown type",
861 QString().sprintf(
": addDescriptor(): the descriptor [%s] has wrong dimensions (%d,%d,%d)",
885 QString().sprintf(
"the TOC number of the descriptor [%s] was adjusted from %d to %d",
895 int minSize, teMinSize;
896 minSize = tcBlock->
listOfTeBlocks()->at(0)->listOfDescriptors()->size();
898 for (
int teCount=0; teCount<tcBlock->
listOfTeBlocks()->size(); teCount++)
899 if (minSize>=tcBlock->
listOfTeBlocks()->at(teCount)->listOfDescriptors()->size())
901 minSize = tcBlock->
listOfTeBlocks()->at(teCount)->listOfDescriptors()->size();
909 QString().sprintf(
": addDescriptor(): the descriptor [%s] has wrong TE number %d",
928 ": delDescriptor(): called when the image is not in proper state");
934 ": delDescriptor(): descriptor is NULL");
945 QString().sprintf(
": delDescriptor(): the descriptor [%s] is not a member of the list",
954 QString().sprintf(
": delDescriptor(): the specified nTc (%d) is less than"
955 " the number of TOCs (%d) for the parameter [%s]",
962 QString().sprintf(
": delDescriptor(): the descriptor [%s] is not a member of the TOC#%d",
1015 s.setByteOrder(QDataStream::BigEndian);
1022 "DBH I/O: the start block is wrong; ignoring file");
1032 *image.
dumpStream_ <<
"== History Block dump: ==" << endl;
1033 while (!historyEntry->
isLast() && historyEntry->
isOk())
1036 if (historyEntry->isHistoryLine())
1045 *image.
dumpStream_ <<
"== End of dump ==" << endl;
1046 delete historyEntry;
1058 int declaredNumberOfObservations=-1;
1061 declaredNumberOfObservations = image.
getJ4(d, 0,0,0);
1066 declaredNumberOfObservations = image.
getI2(d, 0,0,0);
1070 int observationNumber=-1;
1072 while (!s.atEnd() && F.
isOk())
1081 observationNumber++;
1097 if (declaredNumberOfObservations>0 &&
1100 QString().sprintf(
"DBH I/O: The number of read observations (%d) differs from the"
1101 " the declared number in the TOC#0 (%d)",
1105 QString().sprintf(
"DBH I/O: read %d observations",
1118 s.setByteOrder(QDataStream::BigEndian);
1129 for (
int i=0; i<image.
history_.size(); i++)
1131 historyEntry = image.
history_.at(i);
1138 delete historyEntry;
SgDbhStream & operator<<(SgDbhStream &s, const SgDbhImage &image)
SgDbhStream & operator>>(SgDbhStream &s, SgDbhImage &image)
QHash< int, SgDbhPhysicalRecord * > * recordByType()
QList< SgDbhPhysicalRecord * > * listOfRecords()
static const QString typeNames_[6]
void setDescription(const QString &description)
void setLCode(const QString &lCode)
const QString & getLCode() const
SgDbhDatumDescriptor & operator=(const SgDbhDatumDescriptor &descriptor)
void setOffset(int offset)
void setModifiedAtVersion(int V)
void setEvent(const QString &, const QString &, int, const SgMJD &)
void dump(QTextStream &s) const
void writeDataRecords(SgDbhStream &, const QList< SgDbhDataBlock * > *, int) const
const QString & fileName() const
void updateDescriptorsParameters()
QList< SgDbhHistoryEntry * > history_
const QString & sessionID() const
void startFormatModifying()
double getR8(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber=-1)
short getI2(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber=-1)
QList< SgDbhDataBlock * > listOfDataBlocksToc0_
C getData(const QString &, SgDbhDatumDescriptor *, int, int, int, int=-1)
void addHistoryEntry(const QString &text, const SgMJD &t=SgMJD::currentMJD().toUtc())
void setI2(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber, short i2)
double getD8(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber=-1)
void setJ4(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber, int j4)
void setData(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber, C r8)
ContentState contentState_
SgMJD fileCreationEpoch() const
QList< SgDbhDatumDescriptor * > listOfNewDescriptors_
SgDbhStartBlock * startBlock_
void setD8(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber, double d8)
void setStr(SgDbhDatumDescriptor *d, int i, int j, int obsNumber, const QString &str)
QList< SgDbhDatumDescriptor * > listOfDeletedDescriptors_
void finisFormatModifying()
const QString & sessionDescription() const
QHash< QString, SgDbhDatumDescriptor * > descriptorByLCode_
QTextStream * dumpStream_
void clearListOfObservations()
const QString & previousFileName() const
bool delDescriptor(SgDbhDatumDescriptor *)
QList< SgDbhObservationEntry * > listOfObservations_
void setR8(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber, double r8)
SgDbhDatumDescriptor * lookupDescriptor(const char *tag)
SgDbhPhysicalRecord * properRecord(SgDbhDatumDescriptor *, int)
void updateDataRecords(QList< SgDbhDataBlock * > *, int)
bool addDescriptor(SgDbhDatumDescriptor *)
bool isSessionCodeAltered_
const QString & previousFileDescription() const
QString getStr(SgDbhDatumDescriptor *d, int i, int j, int obsNumber=-1)
int getJ4(SgDbhDatumDescriptor *d, int i, int j, int k, int obsNumber=-1)
const QString className() const
QList< SgDbhDatumDescriptor * > * listOfDescriptors()
void saveDataBlocksFromTcBlock(int TocNumber, SgDbhTcBlock &tcBlock)
QList< QList< SgDbhDataBlock * > * > & listOfTcsData()
QList< SgDbhDataBlock * > * dataBlocksFromTocI(int tocNumber) const
virtual void reSize(int length)
void setNumOfPhRecs(int num)
void setNumOfTeBlocks(int num)
void setPrefix(const char prefix[2])
void rotateVersion(int newVersion, const QString &newFileName)
const QString & prevDescript() const
const QString & prevDb() const
void dump(QTextStream &) const
void alternateCode(const QString &)
const QString & expDescript() const
const QString & dbName() const
const QString & sessionID() const
QList< SgDbhTeBlock * > * listOfTeBlocks()
QHash< QString, SgDbhDatumDescriptor * > * descriptorByLCode()
void dump(QTextStream &s) const
const SgDbhServiceRecordTe & recTe()
void setIsFormatModified(bool Is)
bool isFormatModified() const
virtual void write(LogLevel, quint32, const QString &, bool=false)