1 #ifndef COBRACORRELATIONDATA_H
2 #define COBRACORRELATIONDATA_H
12 class CobraCorrelationData :
15 CobraCorrelationData() :
16 status_(0), mode_(0), nint_(0) {}
17 ~CobraCorrelationData(){}
25 int getSizeInBytes()
const {
29 void mySerialize(
char *
const byteArray,
30 int *
const offset )
const
32 pack(status_, byteArray, offset);
33 pack(mode_, byteArray, offset);
34 pack(nint_, byteArray, offset);
37 void deserializeVer0(
const char *
const byteArray,
41 unpack(status_, byteArray, offset, byteArraySize);
42 unpack(mode_, byteArray, offset, byteArraySize);
43 unpack(nint_, byteArray, offset, byteArraySize);
46 void deserializeVer1(
const char *
const byteArray,
50 unpack(status_, byteArray, offset, byteArraySize);
51 unpack(mode_, byteArray, offset, byteArraySize);
52 unpack(nint_, byteArray, offset, byteArraySize);
55 void deserializeSwapVer0(
const char *
const byteArray,
59 unpackSwap(status_, byteArray, offset, byteArraySize);
60 unpackSwap(mode_, byteArray, offset, byteArraySize);
61 unpackSwap(nint_, byteArray, offset, byteArraySize);
64 void deserializeSwapVer1(
const char *
const byteArray,
68 unpackSwap(status_, byteArray, offset, byteArraySize);
69 unpackSwap(mode_, byteArray, offset, byteArraySize);
70 unpackSwap(nint_, byteArray, offset, byteArraySize);
74 bool operator== (
const CobraCorrelationData &rhs)
76 return ((status_ == rhs.status_) &&
77 (mode_ == rhs.mode_) &&
78 (nint_ == rhs.nint_));
80 bool operator!= (
const CobraCorrelationData &rhs)
82 return !(*
this == rhs);
100 void setStatus(
int status)
102 void setMode(
int mode)
104 void setNint(
int nint)
116 class CobraAutoSpectra :
117 public CobraCorrelationData {
119 CobraAutoSpectra() : nchannels_(0) {}
120 ~CobraAutoSpectra(){}
125 int size = CobraCorrelationData::size();
126 size += nchannels_*
sizeof(float);
130 int getSizeInBytes()
const {
134 void mySerialize(
char *
const byteArray,
135 int *
const offset )
const
138 CobraCorrelationData::mySerialize(byteArray, offset);
141 pack(data_, byteArray, offset);
144 void deserializeVer0(
const char *
const byteArray,
149 CobraCorrelationData::deserializeVer0(byteArray,
155 data_.resize(nchannels_);
156 unpack(data_, byteArray, offset, byteArraySize);
159 void deserializeVer1(
const char *
const byteArray,
164 CobraCorrelationData::deserializeVer1(byteArray,
170 data_.resize(nchannels_);
171 unpack(data_, byteArray, offset, byteArraySize);
174 void deserializeSwapVer0(
const char *
const byteArray,
179 CobraCorrelationData::deserializeSwapVer0(byteArray,
185 data_.resize(nchannels_);
186 unpackSwap(data_, byteArray, offset, byteArraySize);
189 void deserializeSwapVer1(
const char *
const byteArray,
194 CobraCorrelationData::deserializeSwapVer1(byteArray,
200 data_.resize(nchannels_);
201 unpackSwap(data_, byteArray, offset, byteArraySize);
205 bool operator== (
const CobraAutoSpectra &rhs)
208 if (CobraCorrelationData::operator==(rhs) ==
false) {
211 return (data_ == rhs.data_);
213 bool operator!= (
const CobraAutoSpectra &rhs)
215 return !(*
this == rhs);
223 std::vector<float> getData()
232 void setData(std::vector<float> data)
235 if (nchannels_ == 0) {
236 nchannels_ = data_.size();
244 void setNumChannels(
int num)
249 std::vector<float> data_;
252 class CobraCrossSpectra :
253 public CobraCorrelationData {
255 CobraCrossSpectra() : nchannels_(0) {}
256 ~CobraCrossSpectra(){}
262 int size = CobraCorrelationData::size();
263 size += 2*nchannels_*2*
sizeof(float);
267 int getSizeInBytes()
const {
271 void mySerialize(
char *
const byteArray,
272 int *
const offset )
const
275 CobraCorrelationData::mySerialize(byteArray, offset);
278 for (
int i = 0; i < 2; i++) {
279 pack(data_[i], byteArray, offset);
283 void deserializeVer0(
const char *
const byteArray,
288 CobraCorrelationData::deserializeVer0(byteArray,
293 for (
int i = 0; i < 2; i++) {
294 data_[i].resize(nchannels_);
295 unpack(data_[i], byteArray, offset, byteArraySize);
299 void deserializeVer1(
const char *
const byteArray,
304 CobraCorrelationData::deserializeVer1(byteArray,
309 for (
int i = 0; i < 2; i++) {
310 data_[i].resize(nchannels_);
311 unpack(data_[i], byteArray, offset, byteArraySize);
315 void deserializeSwapVer0(
const char *
const byteArray,
320 CobraCorrelationData::deserializeSwapVer0(byteArray,
325 for (
int i = 0; i < 2; i++) {
326 data_[i].resize(nchannels_);
327 unpackSwap(data_[i], byteArray, offset, byteArraySize);
331 void deserializeSwapVer1(
const char *
const byteArray,
336 CobraCorrelationData::deserializeSwapVer1(byteArray,
341 for (
int i = 0; i < 2; i++) {
342 data_[i].resize(nchannels_);
343 unpackSwap(data_[i], byteArray, offset, byteArraySize);
348 bool operator== (
const CobraCrossSpectra &rhs)
351 if (CobraCorrelationData::operator==(rhs) ==
false) {
354 return (data_ == rhs.data_);
356 bool operator!= (
const CobraCrossSpectra &rhs)
358 return !(*
this == rhs);
366 std::vector<std::complex<float> > getData(
unsigned int num)
369 return data_.at(num);
379 std::vector<std::complex<float> > data,
386 if (num + 1 > data_.size()) {
387 data_.resize(num + 1);
389 data_.at(num) = data;
390 if (nchannels_ == 0) {
391 nchannels_ = data.size();
399 void setNumChannels(
int num)
406 std::vector<std::vector<std::complex<float> > > data_;
412 #endif // COBRACORRELATIONDATA_H
Abstract Class used to allow object to serialize themselves into a byte array.
modeType getMode(idType id)
Extract the address mode from a 29 bit can id.