casacore
header.h
Go to the documentation of this file.
1 #ifndef DYSCO_HEADER_H
2 #define DYSCO_HEADER_H
3 
4 #include "serializable.h"
5 
6 #include <stdint.h>
7 
8 namespace dyscostman {
9 
10 #ifndef DOXYGEN_SHOULD_SKIP_THIS
11 struct Header : public Serializable {
13  uint32_t headerSize;
15  uint32_t columnHeaderOffset;
17  uint32_t columnCount;
18 
19  std::string storageManagerName;
20 
21  uint32_t rowsPerBlock;
22  uint32_t antennaCount;
23  uint32_t blockSize;
24 
26  uint16_t versionMajor, versionMinor;
27 
28  uint8_t dataBitCount;
29  uint8_t weightBitCount;
30  uint8_t distribution;
31  uint8_t normalization;
32  double studentTNu, distributionTruncation;
33 
34  uint32_t calculateColumnHeaderOffset() const {
35  return 7 * 4 + // 6 x uint32 + string length
36  storageManagerName.size() + 2 * 2 + // 2 x uint16
37  4 * 1 + // 4 x uint8
38  2 * 8; // 2 x double
39  }
40 
41  virtual void Serialize(std::ostream &stream) const final override {
42  SerializeToUInt32(stream, headerSize);
43  SerializeToUInt32(stream, columnHeaderOffset);
44  SerializeToUInt32(stream, columnCount);
45  SerializeTo32bString(stream, storageManagerName);
46  SerializeToUInt32(stream, rowsPerBlock);
47  SerializeToUInt32(stream, antennaCount);
48  SerializeToUInt32(stream, blockSize);
49  SerializeToUInt16(stream, versionMajor);
50  SerializeToUInt16(stream, versionMinor);
51  SerializeToUInt8(stream, dataBitCount);
52  SerializeToUInt8(stream, weightBitCount);
53  SerializeToUInt8(stream, distribution);
54  SerializeToUInt8(stream, normalization);
55  SerializeToDouble(stream, studentTNu);
56  SerializeToDouble(stream, distributionTruncation);
57  }
58 
59  virtual void Unserialize(std::istream &stream) final override {
60  headerSize = UnserializeUInt32(stream);
61  columnHeaderOffset = UnserializeUInt32(stream);
62  columnCount = UnserializeUInt32(stream);
63 
64  Unserialize32bString(stream, storageManagerName);
65 
66  rowsPerBlock = UnserializeUInt32(stream);
67  antennaCount = UnserializeUInt32(stream);
68  blockSize = UnserializeUInt32(stream);
69 
71  versionMajor = UnserializeUInt16(stream);
72  versionMinor = UnserializeUInt16(stream);
73 
74  dataBitCount = UnserializeUInt8(stream);
75  weightBitCount = UnserializeUInt8(stream);
76  distribution = UnserializeUInt8(stream);
77  normalization = UnserializeUInt8(stream);
78  studentTNu = UnserializeDouble(stream);
79  distributionTruncation = UnserializeDouble(stream);
80  }
81 
82  // the column headers start here (first generic header, then column specific
83  // header)
84 };
85 
86 struct GenericColumnHeader : public Serializable {
88  uint32_t columnHeaderSize;
89 
90  virtual void Serialize(std::ostream &stream) const override {
91  SerializeToUInt32(stream, columnHeaderSize);
92  }
93 
94  virtual void Unserialize(std::istream &stream) override {
95  columnHeaderSize = UnserializeUInt32(stream);
96  }
97 
98  virtual uint32_t calculateSize() const { return 4; }
99 };
100 }
101 
102 #endif
103 
104 #endif