nidas  v1.2-1520
sample_type_traits.h
Go to the documentation of this file.
1 #ifndef NIDAS_CORE_SAMPLE_TRAITS
2 #define NIDAS_CORE_SAMPLE_TRAITS
3 
4 namespace nidas { namespace core {
5 
10 inline unsigned int maxValue(unsigned short)
11 {
12  return USHRT_MAX;
13 }
14 
15 inline unsigned int maxValue(short)
16 {
17  return SHRT_MAX;
18 }
19 
20 inline unsigned int maxValue(int)
21 {
22  return INT_MAX;
23 }
24 
25 inline unsigned int maxValue(unsigned int)
26 {
27  return UINT_MAX;
28 }
29 
30 typedef enum sampleType {
34 
35 
36 
37 template <typename T>
39 {
40  typedef T sample_type;
41  typedef T* sample_type_pointer;
42 };
43 
44 template <typename T>
46 {
47 };
48 
49 template <>
50 struct sample_type_traits<char>
51 {
52  static const sampleType sample_type_enum = CHAR_ST;
53 };
54 
55 template <>
56 struct sample_type_traits<unsigned char>
57 {
58  static const sampleType sample_type_enum = UCHAR_ST;
59 };
60 
61 template <>
62 struct sample_type_traits<unsigned short>
63 {
64  static const sampleType sample_type_enum = USHORT_ST;
65 };
66 
67 template <>
68 struct sample_type_traits<short>
69 {
70  static const sampleType sample_type_enum = SHORT_ST;
71 };
72 
73 template <>
74 struct sample_type_traits<unsigned int>
75 {
76  static const sampleType sample_type_enum = UINT32_ST;
77 };
78 
79 template <>
80 struct sample_type_traits<int>
81 {
82  static const sampleType sample_type_enum = INT32_ST;
83 };
84 
85 template <>
86 struct sample_type_traits<float>
87 {
88  static const sampleType sample_type_enum = FLOAT_ST;
89 };
90 
91 template <>
92 struct sample_type_traits<double>
93 {
94  static const sampleType sample_type_enum = DOUBLE_ST;
95 };
96 
97 template <>
98 struct sample_type_traits<long long>
99 {
100  static const sampleType sample_type_enum = INT64_ST;
101 };
102 
103 template <>
104 struct sample_type_traits<void>
105 {
106  static const sampleType sample_type_enum = UNKNOWN_ST;
107 };
108 
109 
110 template <typename T>
112 {
114 }
115 
116 
117 }} //namespace nidas::core
118 
119 #endif // NIDAS_CORE_SAMPLE_TRAITS
Definition: sample_type_traits.h:32
sampleType
Definition: sample_type_traits.h:30
sampleType getSampleType(T *)
Definition: sample_type_traits.h:111
Definition: sample_type_traits.h:31
Definition: sample_type_traits.h:31
unsigned int maxValue(unsigned short)
maxValue is an overloaded function returning the maximum value of its integer argument.
Definition: sample_type_traits.h:10
Definition: sample_type_traits.h:32
Definition: sample_type_traits.h:32
Definition: sample_type_traits.h:33
Definition: sample_type_traits.h:32
T * sample_type_pointer
Definition: sample_type_traits.h:41
Definition: sample_type_traits.h:31
T sample_type
Definition: sample_type_traits.h:40
Definition: sample_type_traits.h:31
Definition: sample_type_traits.h:33
Definition: sample_type_traits.h:38
Definition: sample_type_traits.h:45