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