CARMA C++
CorrelatorBand.h
1 #ifndef SZA_UTIL_CORRELATORBAND_H
2 #define SZA_UTIL_CORRELATORBAND_H
3 
11 #include <iostream>
12 #include <sstream>
13 #include <string>
14 
15 #include "carma/szautil/Directives.h"
16 #include "carma/szautil/Frequency.h"
17 
18 namespace sza {
19  namespace util {
20 
25 
26  //------------------------------------------------------------
27  // Public members
28  //------------------------------------------------------------
29 
30  public:
31 
32  // The total number of 500 MHz bands
33 
34  static const unsigned int NBAND = 16;
35 
36  // Each 500 MHz band is correlated in NCHAN channels. The lag
37  // correlator actually produces 17 channels, but the end points
38  // are aliased. We will pack only the central N-2 bands
39 
40  static const unsigned int NCHAN_TOTAL = 17;
41 
45  enum Id {
46  BANDNONE = 0x0, // Make these orthogonal bits, so we can OR
47  // them together.
48  BAND0 = 0x1,
49  BAND1 = 0x2,
50  BAND2 = 0x4,
51  BAND3 = 0x8,
52  BAND4 = 0x10,
53  BAND5 = 0x20,
54  BAND6 = 0x40,
55  BAND7 = 0x80,
56  BAND8 = 0x100,
57  BAND9 = 0x200,
58  BAND10 = 0x400,
59  BAND11 = 0x800,
60  BAND12 = 0x1000,
61  BAND13 = 0x2000,
62  BAND14 = 0x4000,
63  BAND15 = 0x8000,
64  BANDMAX = BAND15, // This should always be set to the last valid band
65  BANDALL = 0xFFFF,
66  } id_;
67 
71  CorrelatorBand(Id id);
72 
78  CorrelatorBand(unsigned int);
79 
84 
90  CorrelatorBand(const CorrelatorBand& band);
91 
95  bool isValidSingleBand();
96 
100  std::string bandName();
101  static std::string bandName(unsigned iBand);
102 
106  void setId(CorrelatorBand::Id id);
107 
115  unsigned int getIntId();
116 
121  unsigned short getDcBandIndex();
122  unsigned short getDcNodeIndex();
123 
127  unsigned int getBandMax();
128 
133  bool isSet(CorrelatorBand::Id id);
134 
139  bool isSet(CorrelatorBand& band);
140 
141  //------------------------------------------------------------
142  // Member operators
143  //------------------------------------------------------------
144 
148  const CorrelatorBand operator+(const CorrelatorBand& band);
149 
153  bool operator<(const CorrelatorBand band);
154 
158  bool operator<=(const CorrelatorBand band);
159 
163  bool operator>(const CorrelatorBand band);
164 
168  bool operator>=(const CorrelatorBand band);
169 
173  bool operator==(const CorrelatorBand band);
174 
178  const CorrelatorBand& operator++();
179 
183  const CorrelatorBand operator++(int);
184 
185  //------------------------------------------------------------
186  // Non-member operator methods
187  //------------------------------------------------------------
188 
192  friend std::ostream& operator<<(std::ostream& os, const CorrelatorBand& band);
193 
197  friend std::ostringstream& operator<<(std::ostringstream& os,
198  const CorrelatorBand& band);
203  const CorrelatorBand::Id id2);
204 
208  static Frequency bandWidth();
209 
213  static Frequency bandWidthPerChannel();
214 
215  //------------------------------------------------------------
216  // Private members
217  //------------------------------------------------------------
218 
219  private:
220 
221  // The bandwidth of a band
222 
223  static const Frequency bandWidth_;
224 
225  // The bandwidth of a single channel
226 
227  static const Frequency bandWidthPerChannel_;
228 
232  bool isValid(unsigned int band);
233 
237  Id intToId(unsigned int iband);
238 
242  void checkMaxBand();
243 
244  }; // End class CorrelatorBand
245 
249  std::ostream& operator<<(std::ostream& os, const CorrelatorBand& band);
250 
254  std::ostringstream& operator<<(std::ostringstream& os,
255  const CorrelatorBand& band);
259  CorrelatorBand::Id operator+(const CorrelatorBand::Id id1,
260  const CorrelatorBand::Id id2);
261 
262  }; // End namespace util
263 }; // End namespace sza
264 
265 #endif
266 
bool operator<(const CorrelatorBand band)
Define &lt; for two band enumerators.
bool operator>=(const CorrelatorBand band)
Define &gt;= for two band enumerators.
Id
Enumerate known bands.
static Frequency bandWidth()
......................................................................
void setId(CorrelatorBand::Id id)
Set the id of this antenna enumerator.
bool operator>(const CorrelatorBand band)
Define &gt; for two band enumerators.
unsigned int getIntId()
Return an integer band index associated with this enumerator.
bool isValidSingleBand()
Check if this object specifies a valid single band.
unsigned short getDcBandIndex()
Return an integer band index suitable for passing to the downconverter API.
bool operator==(const CorrelatorBand band)
Define equality for two band enumerators.
bool operator<=(const CorrelatorBand band)
Define &lt;= for two band enumerators.
CorrelatorBand()
Constructor with uninitialized band.
bool isSet(CorrelatorBand::Id id)
Return true if the passed is is part of this object&#39;s band set.
friend std::ostream & operator<<(std::ostream &os, const CorrelatorBand &band)
Allows cout &lt;&lt; band.
A class to enumerate a single Band, or a set of Bands.
static Frequency bandWidthPerChannel()
......................................................................
const CorrelatorBand operator+(const CorrelatorBand &band)
Add two band enumerators.
std::string bandName()
Return string representing this band.
const CorrelatorBand & operator++()
Prefix increment.
unsigned int getBandMax()
Return the maximum number of bands we know about.