source: trunk/Mars/mcore/FITS.h@ 17261

Last change on this file since 17261 was 17249, checked in by tbretz, 11 years ago
Added a special constructor version to make CINT happy and me unhappy.
File size: 2.8 KB
Line 
1/*
2 *
3 * FITS.h
4 *
5 * Global fits header
6 *
7 * Author: lyard
8 *
9 */
10
11#ifndef _FITS_H_
12#define _FITS_H_
13
14//#include <string>
15
16namespace FITS
17{
18
19 //Identifier of the compression schemes processes
20 enum CompressionProcess_t
21 {
22 kFactRaw = 0x0,
23 kFactSmoothing = 0x1,
24 kFactHuffman16 = 0x2
25 };
26
27 //ordering of the columns / rows
28 enum RowOrdering_t
29 {
30 kOrderByCol = 'C',
31 kOrderByRow = 'R'
32 };
33
34
35#ifndef __CINT__
36
37 //Structure helper for tiles headers
38 struct TileHeader
39 {
40 char id[4];
41 uint32_t numRows;
42 uint64_t size;
43
44 TileHeader() {}
45
46 TileHeader(uint32_t nRows,
47 uint64_t s) : id({'T', 'I', 'L', 'E'}),
48 numRows(nRows),
49 size(s)
50 { };
51 } __attribute__((__packed__));
52
53 //Structure helper for blocks headers and compresion schemes
54 struct BlockHeader
55 {
56 uint64_t size;
57 char ordering;
58 unsigned char numProcs;
59 uint16_t processings[];
60
61 BlockHeader(uint64_t s=0,
62 char o=kOrderByRow,
63 unsigned char n=1) : size(s),
64 ordering(o),
65 numProcs(n)
66 {}
67 } __attribute__((__packed__));
68
69 //Helper structure to simplify the initialization and handling of compressed blocks headers
70 struct Compression
71 {
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)
77 {
78
79 }
80
81 Compression(const CompressionProcess_t &compression=kFactRaw, const RowOrdering_t &order=kOrderByCol)
82 : header(0, order, 1), sequence(1)
83 {
84 sequence[0] = compression;
85 }
86
87#ifdef __MARS__
88 Compression(const int &compression)
89 : header(0, kOrderByCol, 1), sequence(1)
90 {
91 sequence[0] = compression;
92 }
93#endif
94
95 RowOrdering_t getOrdering() const { return RowOrdering_t(header.ordering); }
96 uint32_t getSizeOnDisk() const { return sizeof(BlockHeader) + sizeof(uint16_t)*header.numProcs; }
97 CompressionProcess_t getProc(uint32_t i) const { return CompressionProcess_t(sequence[i]); }
98 uint16_t getNumProcs() const { return header.numProcs; }
99
100 void SetBlockSize(uint64_t size) { header.size = size; }
101 void Memcpy(char *dest) const
102 {
103 memcpy(dest, &header, sizeof(BlockHeader));
104 memcpy(dest+sizeof(BlockHeader), sequence.data(), header.numProcs*sizeof(uint16_t));
105 }
106
107
108 };
109
110
111#endif
112};
113
114#endif //_FITS_H_
115
Note: See TracBrowser for help on using the repository browser.