libsdr  0.1.0
A simple SDR library
traits.hh
1 #ifndef __SDR_TRAITS_HH__
2 #define __SDR_TRAITS_HH__
3 
4 #include <inttypes.h>
5 #include <complex>
6 #include "node.hh"
7 
8 namespace sdr {
9 
20 template <class Scalar> class Traits;
21 
23 template <>
24 class Traits<uint8_t> {
25 public:
27  typedef uint8_t Scalar;
29  typedef uint8_t RScalar;
31  typedef uint16_t SScalar;
33  const static float scale;
35  const static size_t shift;
37  const static Config::Type scalarId = Config::Type_u8;
38 };
39 
41 template <>
42 class Traits< std::complex<uint8_t> > {
43 public:
45  typedef std::complex<uint8_t> Scalar;
47  typedef uint8_t RScalar;
49  typedef std::complex<uint16_t> SScalar;
51  const static float scale;
53  const static size_t shift;
55  const static Config::Type scalarId = Config::Type_cu8;
56 };
57 
59 template <>
60 class Traits<int8_t> {
61 public:
63  typedef int8_t Scalar;
65  typedef int8_t RScalar;
67  typedef int16_t SScalar;
69  const static float scale;
71  const static size_t shift;
73  const static Config::Type scalarId = Config::Type_s8;
74 };
75 
77 template <>
78 class Traits< std::complex<int8_t> > {
79 public:
81  typedef std::complex<int8_t> Scalar;
83  typedef int8_t RScalar;
85  typedef std::complex<int16_t> SScalar;
87  const static float scale;
89  const static size_t shift;
91  const static Config::Type scalarId = Config::Type_cs8;
92 };
93 
95 template <>
96 class Traits<uint16_t> {
97 public:
99  typedef uint16_t Scalar;
101  typedef uint16_t RScalar;
103  typedef uint32_t SScalar;
105  const static float scale;
107  const static size_t shift;
109  const static Config::Type scalarId = Config::Type_u16;
110 };
111 
113 template <>
114 class Traits< std::complex<uint16_t> > {
115 public:
117  typedef std::complex<uint16_t> Scalar;
119  typedef uint16_t RScalar;
121  typedef std::complex<uint32_t> SScalar;
123  const static float scale;
125  const static size_t shift;
127  const static Config::Type scalarId = Config::Type_cu16;
128 };
129 
131 template <>
132 class Traits<int16_t> {
133 public:
135  typedef int16_t Scalar;
137  typedef int16_t RScalar;
139  typedef int32_t SScalar;
141  const static float scale;
143  const static size_t shift;
145  const static Config::Type scalarId = Config::Type_s16;
146 };
147 
149 template <>
150 class Traits< std::complex<int16_t> > {
151 public:
153  typedef std::complex<int16_t> Scalar;
155  typedef int16_t RScalar;
157  typedef std::complex<int32_t> SScalar;
159  const static float scale;
161  const static size_t shift;
163  const static Config::Type scalarId = Config::Type_cs16;
164 };
165 
167 template <>
168 class Traits<float> {
169 public:
171  typedef float Scalar;
173  typedef float RScalar;
175  typedef float SScalar;
177  const static float scale;
179  const static size_t shift;
181  const static Config::Type scalarId = Config::Type_f32;
182 };
183 
185 template <>
186 class Traits< std::complex<float> > {
187 public:
189  typedef std::complex<float> Scalar;
191  typedef float RScalar;
193  typedef std::complex<float> SScalar;
195  const static float scale;
197  const static size_t shift;
199  const static Config::Type scalarId = Config::Type_cf32;
200 };
201 
203 template <>
204 class Traits<double> {
205 public:
207  typedef double Scalar;
209  typedef double RScalar;
211  typedef double SScalar;
213  const static float scale;
215  const static size_t shift;
217  const static Config::Type scalarId = Config::Type_f64;
218 };
219 
221 template <>
222 class Traits< std::complex<double> > {
223 public:
225  typedef std::complex<double> Scalar;
227  typedef double RScalar;
229  typedef std::complex<double> SScalar;
231  const static float scale;
233  const static size_t shift;
235  const static Config::Type scalarId = Config::Type_cf64;
236 };
237 
238 
239 }
240 
241 #endif
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:123
Complex (aka I/Q) type of 32bit floats aka. std::complex.
Definition: node.hh:51
int8_t RScalar
The real scalar type.
Definition: traits.hh:83
uint16_t Scalar
The scalar type.
Definition: traits.hh:99
std::complex< uint32_t > SScalar
The compute scalar type.
Definition: traits.hh:121
int16_t RScalar
The real scalar type.
Definition: traits.hh:137
uint16_t RScalar
The real scalar type.
Definition: traits.hh:101
Real signed 16b ints.
Definition: node.hh:44
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:197
float SScalar
The compute scalar type.
Definition: traits.hh:175
std::complex< double > Scalar
The scalar type.
Definition: traits.hh:225
Complex (aka I/Q) type of unsigned 16b ints.
Definition: node.hh:49
Definition: autocast.hh:8
double Scalar
The scalar type.
Definition: traits.hh:207
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:233
Real signed 8b ints.
Definition: node.hh:42
uint32_t SScalar
The compute scalar type.
Definition: traits.hh:103
Definition: operators.hh:9
double RScalar
The real scalar type.
Definition: traits.hh:227
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:107
Real unsigned 8b ints.
Definition: node.hh:41
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:159
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:125
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:51
int16_t Scalar
The scalar type.
Definition: traits.hh:135
int16_t RScalar
The real Scalar type.
Definition: traits.hh:155
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:141
std::complex< int32_t > SScalar
The compute scalar type.
Definition: traits.hh:157
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:161
Real 64b floats aka. "double".
Definition: node.hh:46
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:87
Real unsigned 16b ints.
Definition: node.hh:43
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:179
float Scalar
The Scalar type.
Definition: traits.hh:171
uint8_t RScalar
The real scalar type.
Definition: traits.hh:47
double SScalar
The compute scalar type.
Definition: traits.hh:211
std::complex< double > SScalar
The compute (super) scalar type.
Definition: traits.hh:229
uint16_t RScalar
The real scalar type.
Definition: traits.hh:119
int8_t RScalar
The real scalar type.
Definition: traits.hh:65
std::complex< float > Scalar
The scalar type.
Definition: traits.hh:189
uint8_t RScalar
The real scalar type.
Definition: traits.hh:29
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:89
uint16_t SScalar
The compute scalar type.
Definition: traits.hh:31
int16_t SScalar
The compute scalar type.
Definition: traits.hh:67
uint8_t Scalar
The scalar type.
Definition: traits.hh:27
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:71
std::complex< float > SScalar
The compute scalar type.
Definition: traits.hh:193
std::complex< int8_t > Scalar
The scalar type.
Definition: traits.hh:81
int32_t SScalar
The compute scalar type.
Definition: traits.hh:139
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:33
Real 32b floats aka. "float".
Definition: node.hh:45
std::complex< uint16_t > Scalar
The scalar type.
Definition: traits.hh:117
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:213
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:143
std::complex< int16_t > SScalar
The compute scalar type.
Definition: traits.hh:85
Type
The type IDs.
Definition: node.hh:39
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:231
std::complex< int16_t > Scalar
The scalar type.
Definition: traits.hh:153
Complex (aka I/Q) type of signed 8b ints.
Definition: node.hh:48
std::complex< uint16_t > SScalar
The compute scalar type.
Definition: traits.hh:49
std::complex< uint8_t > Scalar
The scalar type.
Definition: traits.hh:45
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:195
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:177
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:105
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:53
Complex (aka I/Q) type of signed 16b ints.
Definition: node.hh:50
Complex (aka I/Q) type of unsigned 8b ints.
Definition: node.hh:47
float RScalar
The real scalar type.
Definition: traits.hh:191
Forward declaration of type tratis template.
Definition: traits.hh:20
int8_t Scalar
The scalar type.
Definition: traits.hh:63
static const size_t shift
The scaleing factor from floating point to integer expressed as 2^exp.
Definition: traits.hh:215
float RScalar
The real scalar type.
Definition: traits.hh:173
static const float scale
The scaleing factor from floating point to integer.
Definition: traits.hh:69
static const size_t shift
Shift from Scalar to SScalar.
Definition: traits.hh:35
double RScalar
The real scalar type.
Definition: traits.hh:209
Complex (aka I/Q) type of 64bit floats aka. std::complex.
Definition: node.hh:52