Changeset 17223 for trunk/Mars
- Timestamp:
- 10/16/13 19:17:30 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/FITS.h
r17222 r17223 68 68 69 69 //Helper structure to simplify the initialization and handling of compressed blocks headers 70 struct BlockHeaderWriter70 struct Compression 71 71 { 72 BlockHeaderWriter(const std::string& comp="") : header(), 73 sequence() 72 BlockHeader header; 73 std::vector<uint16_t> sequence; 74 75 Compression(const std::vector<uint16_t> &seq, const RowOrdering_t &order=kOrderByCol) 76 : header(0, order, seq.size()), sequence(seq) 74 77 { 75 if (comp == "" || comp == "RAW")76 {77 sequence.emplace_back(kFactRaw);78 return;79 }80 if (comp == "SMOOTHMAN")81 {82 header = BlockHeader(0, kOrderByRow, 2);83 sequence.emplace_back(kFactSmoothing);84 sequence.emplace_back(kFactHuffman16);85 return;86 }87 78 88 std::ostringstream str;89 str << "Unkown compression requested: " << comp;90 #ifdef __EXCEPTIONS91 throw std::runtime_error(str.str());92 #else93 gLog << ___err___ << "ERROR - " << str.str();94 return;95 #endif96 79 } 97 80 98 void Write(char* to) 81 Compression(const CompressionProcess_t &compression=kFactRaw, const RowOrdering_t &order=kOrderByCol) 82 : header(0, order, 1), sequence(1) 99 83 { 100 memcpy(to, &header, sizeof(BlockHeader)); 101 memcpy(to+sizeof(BlockHeader), sequence.data(), header.numProcs*sizeof(uint16_t)); 84 sequence[0] = compression; 102 85 } 103 86 104 uint32_t SizeOnDisk() { return sizeof(BlockHeader) + sizeof(uint16_t)*header.numProcs;} 87 RowOrdering_t getOrdering() const { return RowOrdering_t(header.ordering); } 88 uint32_t getSizeOnDisk() const { return sizeof(BlockHeader) + sizeof(uint16_t)*header.numProcs; } 89 CompressionProcess_t getProc(uint32_t i) const { return CompressionProcess_t(sequence[i]); } 90 uint16_t getNumProcs() const { return header.numProcs; } 105 91 106 uint16_t Proc(uint32_t i) { return sequence[i]; } 92 void SetBlockSize(uint64_t size) { header.size = size; } 93 void Memcpy(char *dest) const 94 { 95 memcpy(dest, &header, sizeof(BlockHeader)); 96 memcpy(dest+sizeof(BlockHeader), sequence.data(), header.numProcs*sizeof(uint16_t)); 97 } 107 98 108 uint16_t NumProcs() { return header.numProcs; }109 99 110 char Ordering() { return header.ordering;}100 }; 111 101 112 void SetBlockSize(uint64_t size) { header.size = size;}113 114 BlockHeader header;115 std::vector<uint16_t> sequence;116 };117 102 118 103 #endif
Note:
See TracChangeset
for help on using the changeset viewer.