astrotypes  0.0
DefaultDataFactoryTraits.h
Go to the documentation of this file.
1 /*
2  * MIT License
3  *
4  * Copyright (c) 2018 PulsarSearchSoft
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef PSS_ASTROTYPES_SIGPROC_DEFAULTDATAFACTORYTRAITS_H
25 #define PSS_ASTROTYPES_SIGPROC_DEFAULTDATAFACTORYTRAITS_H
26 
27 
28 namespace pss {
29 namespace astrotypes {
30 namespace sigproc {
31 
38 template<std::size_t nbits>
40  static constexpr unsigned next = 0; // last one
41 };
42 
43 template<>
44 struct BitToUnsignedInt<64> {
45  typedef uint32_t type;
46  static constexpr unsigned next = 0; // last one
47 };
48 
49 template<>
50 struct BitToUnsignedInt<32> {
51  typedef uint32_t type;
52  static constexpr unsigned next = 64;
53 };
54 
55 template<>
56 struct BitToUnsignedInt<16> {
57  typedef uint16_t type;
58  static constexpr unsigned next = 32;
59 };
60 
61 template<>
62 struct BitToUnsignedInt<8> {
63  typedef uint8_t type;
64  static constexpr unsigned next = 16;
65 };
66 
78 template<unsigned nifs, unsigned nbits, template<unsigned> class BitTypeMap>
79 struct ElementType {
80  typedef std::array<typename BitTypeMap<nbits>::type, nifs> type;
81 };
82 
83 template<unsigned nbits, template<unsigned> class BitTypeMap>
84 struct ElementType<1, nbits, BitTypeMap> {
85  typedef typename BitTypeMap<nbits>::type type;
86 };
87 
88 template<unsigned nbits, template<unsigned> class BitTypeMap>
89 struct ElementType<0, nbits, BitTypeMap> {
90  typedef typename BitTypeMap<nbits>::type type;
91 };
92 
97 
98  static constexpr unsigned MaxNifs = 1; // maximum number of data for each channel (e.g 4 polarisations)
99 
101  template<unsigned nbits>
102  struct BitsTypeMap : public BitToUnsignedInt<nbits> {};
103 
105  template<typename T>
106  using AllocatorMap = std::allocator<T>;
107 
113  template<unsigned nifs, unsigned nbits>
115 
116 };
117 
118 
119 } // namespace sigproc
120 } // namespace astrotypes
121 } // namespace pss
122 
123 #endif // PSS_ASTROTYPES_SIGPROC_DEFAULTDATAFACTORYTRAITS_H
std::allocator< T > AllocatorMap
The allocator type of the data types that will be generated.
std::array< typename BitTypeMap< nbits >::type, nifs > type
The mapping of th number of bits to the NumericalRepresentation of those bits.
Maps number_of_bits to unsigned integer types.
Maps number_of_if_streams to the container or raw type.