MeVisLabToolboxReference
MeVis/Foundation/Sources/MLImageFormatBase/mlImageFormatIdxTable.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00006 
00011 //----------------------------------------------------------------------------------
00012 
00013 #ifndef __mlImageFormatIdxTable_H
00014 #define __mlImageFormatIdxTable_H
00015 
00016 // Resolve platform independencies.
00017 #ifndef __MLImageFormatBaseSystem_H
00018 #include "MLImageFormatBaseSystem.h"
00019 #endif
00020 
00021 #ifndef __mlModuleIncludes_H
00022 #include "mlModuleIncludes.h"
00023 #endif
00024 
00025 ML_START_NAMESPACE
00026 
00027 
00029   class MLImageFormatTagList;
00030 
00032   class MLImageFormatInfos;
00033 
00034   //--------------------------------------------------------------------------------
00037   //--------------------------------------------------------------------------------
00038   class MLIMAGEFORMATBASE_EXPORT MLImageFormatIdxTable {
00039 
00040   public:
00041 
00042     //--------------------------------------------------------------------------------
00049     //--------------------------------------------------------------------------------
00050     struct PageIdxType {
00051 
00055       MLint64 startFilePos;
00056 
00059       MLint64 endFilePos;
00060 
00063       MLuint8 isCompressed;
00064 
00066       MLuint8 checkSumLow;
00067 
00069       MLuint8 checkSumMed;
00070 
00072       MLuint8 checkSumHigh;
00073 
00077       MLuint8 flagByte;
00078 
00080       MLuint8 _internalData[11];
00081 
00082       // After _internalData the voxel value of the page is stored; it,
00083       // however, has a size depending on the voxel type and is
00085       // < PageVoxelType > onePageVoxel.
00086 
00088       inline MLuint32 getCheckSum() const
00089       {
00090         return ((static_cast<MLuint32>(checkSumLow )      ) |
00091                 (static_cast<MLuint32>(checkSumMed ) << 8 ) |
00092                 (static_cast<MLuint32>(checkSumHigh) << 16));
00093       }
00094 
00096       inline void setCheckSum(MLuint32 sum)
00097       {
00098         checkSumLow  = (sum      ) & 0xff;
00099         checkSumMed  = (sum >>  8) & 0xff;
00100         checkSumHigh = (sum >> 16) & 0xff;
00101       }
00102 
00104       inline void setFlagByte(MLuint8 newVal)
00105       {
00106         flagByte = newVal;
00107       }
00108 
00110       inline void setPartialFlag(bool isPartialPage)
00111       {
00112         flagByte |= (isPartialPage ? 1 : 0);
00113       }
00114 
00116       inline bool getPartialFlag() const
00117       {
00118         return (flagByte & 1) ? true : false;
00119       }
00120     };
00121 
00122     //--------------------------------------------------------------------------------
00123     //--------------------------------------------------------------------------------
00124 
00126     MLImageFormatIdxTable();
00127 
00129     ~MLImageFormatIdxTable();
00130 
00149     MLErrorCode        create(MLint       startIdx,
00150                               MLint       endIdx,
00151                               MLint       numAllPageIds,
00152                               MLDataType  dType,
00153                               void       *newTableData=NULL,
00154                               bool        setTable=true);
00155 
00162     void               setTableData(void *newTable);
00163 
00166     void               toggleEndianess();
00167 
00169     void               reset();
00170 
00188     MLErrorCode        setEntry(MLint             pageId,
00189                                 MLint             pageDataStartPosInFile,
00190                                 MLint             pageDataEndPosInFile,
00191                                 bool              isCompressed,
00192                                 MLuint32          checkSum,
00193                                 bool              isPartial,
00194                                 const MLTypeData *defaultVoxelData);
00195 
00197     const PageIdxType *getConstEntry(MLint pageId) const;
00198 
00200     PageIdxType       *getEntry(MLint pageId);
00201 
00203     const MLTypeData  *getConstEntryVoxelData(MLint pageId) const;
00204 
00206     MLTypeData        *getEntryVoxelData(MLint pageId);
00207 
00209     MLint              getNumAllocatedPageIds() const;
00210 
00212     MLint              getNumImagePageIds() const;
00213 
00216     MLint              getAllocatedTableSizeInBytes() const;
00217 
00219     MLint              getWholeTableSizeInBytes() const;
00220 
00227     MLErrorCode        load(const MLImageFormatInfos   &infos,
00228                             MLint                      numWholePageIds);
00229 
00239     MLErrorCode         save(int    fd,
00240                              MLuint idxTabBasePos);
00241 
00242     private:
00243 
00245       MLint       _firstEntry;
00246 
00248       MLint       _lastEntry;
00249 
00251       MLint       _numAllocatedTableEntries;
00252 
00254       MLint       _numImagePageIds;
00255 
00257       MLint       _sizeOfOneVoxel;
00258 
00260       MLDataType  _voxelType;
00261 
00263       MLint       _idxTabEntrySize;
00264 
00267       void       *_tablePtr;
00268 
00269   private:
00270 
00272     inline MLImageFormatIdxTable(const MLImageFormatIdxTable &){ }
00273 
00275     inline MLImageFormatIdxTable &operator=(const MLImageFormatIdxTable &){ return *this; }
00276 
00277   };
00278 
00279 ML_END_NAMESPACE
00280 
00281 #endif // __mlImageFormatIdxTable_H