TwoBitMask.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2006 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Kernel/Classes/dsp/TwoBitMask.h
10 
11 #ifndef __TwoBitMask_h
12 #define __TwoBitMask_h
13 
14 #include <iostream>
15 
16 namespace dsp {
17 
19  template<unsigned N>
20  class ShiftMask {
21 
22  public:
23 
24  unsigned shift[N];
25 
27  inline unsigned char operator() (unsigned char data, unsigned isamp)
28  { return (data >> shift[isamp]) & 0x03; }
29 
31  inline unsigned char operator() (unsigned char data)
32  { return (data >> shift[0]) & 0x03; }
33 
34  };
35 
37  template<unsigned N>
38  class GatherMask {
39 
40  public:
41 
42  unsigned shift0[N];
43  unsigned shift1[N];
44 
46  inline unsigned char operator() (unsigned char data, unsigned isamp)
47  { return ((data>>shift0[isamp]) & 0x01)|((data>>shift1[isamp]) & 0x02); }
48 
49  };
50 
51  template<unsigned N>
52  std::ostream& operator<< (std::ostream& ostr, const GatherMask<N>& mask)
53  {
54  for (unsigned i=0; i<N; i++)
55  ostr << mask.shift0[i] << ":" << mask.shift1[i] << " ";
56  return ostr;
57  }
58 
59 }
60 
61 #endif // !defined(__TwoBitMask_h)
62 
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
unsigned char operator()(unsigned char data, unsigned isamp)
Return the shifted 2-bit number.
Definition: TwoBitMask.h:51
Gathers the two bits from separate locations.
Definition: TwoBitMask.h:43
unsigned char operator()(unsigned char data, unsigned isamp)
Return the shifted 2-bit number.
Definition: TwoBitMask.h:37

Generated using doxygen 1.8.17