GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
item_type_helpers.h
Go to the documentation of this file.
1 /*!
2  * \file item_type_helpers.h
3  * \brief Utility functions for converting between item types
4  * \authors <ul>
5  * <li> Cillian O'Driscoll, 2019. cillian.odriscoll(at)gmail.com
6  * </ul>
7  *
8  *
9  * -----------------------------------------------------------------------------
10  *
11  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
12  *
13  * GNSS-SDR is a software defined Global Navigation
14  * Satellite Systems receiver
15  *
16  * This file is part of GNSS-SDR.
17  *
18  * SPDX-License-Identifier: GPL-3.0-or-later
19  *
20  * -----------------------------------------------------------------------------
21  */
22 
23 #ifndef GNSS_SDR_ITEM_TYPE_HELPERS_H
24 #define GNSS_SDR_ITEM_TYPE_HELPERS_H
25 
26 
27 #include <cstdint>
28 #include <functional>
29 #include <string>
30 
31 using item_type_converter_t = std::function<void(void *, const void *, uint32_t)>;
32 
33 /*!
34  * \brief Check if a string is a valid item type
35  *
36  * \description Valid item types include:
37  * "byte", "short", "float", "ibyte", "ishort", "cbyte", "cshort", "gr_complex"
38  *
39  */
40 bool item_type_valid(const std::string &item_type);
41 
42 /*!
43  * \brief Return the size of the given item type, or zero if unknown
44  */
45 size_t item_type_size(const std::string &item_type);
46 
47 /*!
48  * \brief Determine if an item_type is complex
49  */
50 bool item_type_is_complex(const std::string &item_type);
51 
52 /*!
53  * \brief Create a function to convert an array of input_type to an array of output_type
54  *
55  * \description Provides a generic interface to generate conversion functions for mapping
56  * arrays of items.
57  *
58  * \param input_type - String representation of the input item type
59  * \param output_type - String representation of the output item type
60  *
61  * The item types accepted are:
62  *
63  * 1. "byte" for 8 bit integers
64  * 2. "cbyte" for complex (interleaved) 8 bit integers
65  * 4. "ibyte" for complex (interleaved) 8 bit integers
66  * 4. "short" for 16 bit integers
67  * 5. "cshort" for complex (interleaved) 16 bit integers
68  * 6. "ishort" for complex (interleaved) 16 bit integers
69  * 7. "float" for 32 bit floating point values
70  * 8. "gr_complex" for complex (interleaved) 32 bit floating point values
71  *
72  * \returns A function object with the following prototype:
73  * void convert_fun( void *dest, void *src, int num_items );
74  *
75  */
76 item_type_converter_t make_vector_converter(const std::string &input_type,
77  const std::string &output_type);
78 
79 #endif
bool item_type_is_complex(const std::string &item_type)
Determine if an item_type is complex.
size_t item_type_size(const std::string &item_type)
Return the size of the given item type, or zero if unknown.
item_type_converter_t make_vector_converter(const std::string &input_type, const std::string &output_type)
Create a function to convert an array of input_type to an array of output_type.
bool item_type_valid(const std::string &item_type)
Check if a string is a valid item type.