2019-11-04 17:14:50 +00:00
|
|
|
/*!
|
|
|
|
* \file item_type_helpers.h
|
|
|
|
* \brief Utility functions for converting between item types
|
|
|
|
* \authors <ul>
|
2019-11-16 19:09:14 +00:00
|
|
|
* <li> Cillian O'Driscoll, 2019. cillian.odriscoll(at)gmail.com
|
2019-11-04 17:14:50 +00:00
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2019-11-16 19:09:14 +00:00
|
|
|
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
2019-11-04 17:14:50 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2019-11-04 17:14:50 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#ifndef GNSS_SDR_ITEM_TYPE_HELPERS_H
|
|
|
|
#define GNSS_SDR_ITEM_TYPE_HELPERS_H
|
2019-11-04 17:14:50 +00:00
|
|
|
|
|
|
|
|
2020-02-20 10:25:29 +00:00
|
|
|
#include <cstdint>
|
2020-02-20 15:32:59 +00:00
|
|
|
#include <functional>
|
2019-11-04 17:14:50 +00:00
|
|
|
#include <string>
|
|
|
|
|
2020-02-20 10:25:29 +00:00
|
|
|
using item_type_converter_t = std::function<void(void *, const void *, uint32_t)>;
|
2019-11-04 17:14:50 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Check if a string is a valid item type
|
|
|
|
*
|
|
|
|
* \description Valid item types include:
|
2019-11-15 11:39:05 +00:00
|
|
|
* "byte", "short", "float", "ibyte", "ishort", "cbyte", "cshort", "gr_complex"
|
2019-11-04 17:14:50 +00:00
|
|
|
*
|
|
|
|
*/
|
2019-11-08 13:47:08 +00:00
|
|
|
bool item_type_valid(const std::string &item_type);
|
2019-11-04 17:14:50 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Return the size of the given item type, or zero if unknown
|
|
|
|
*/
|
2019-11-08 13:47:08 +00:00
|
|
|
size_t item_type_size(const std::string &item_type);
|
2019-11-04 17:14:50 +00:00
|
|
|
|
2019-11-15 11:39:05 +00:00
|
|
|
/*!
|
|
|
|
* \brief Determine if an item_type is complex
|
|
|
|
*/
|
|
|
|
bool item_type_is_complex(const std::string &item_type);
|
|
|
|
|
2019-11-04 17:14:50 +00:00
|
|
|
/*!
|
|
|
|
* \brief Create a function to convert an array of input_type to an array of output_type
|
|
|
|
*
|
|
|
|
* \description Provides a generic interface to generate conversion functions for mapping
|
|
|
|
* arrays of items.
|
|
|
|
*
|
|
|
|
* \param input_type - String representation of the input item type
|
|
|
|
* \param output_type - String representation of the output item type
|
|
|
|
*
|
|
|
|
* The item types accepted are:
|
|
|
|
*
|
2019-11-15 11:39:05 +00:00
|
|
|
* 1. "byte" for 8 bit integers
|
|
|
|
* 2. "cbyte" for complex (interleaved) 8 bit integers
|
|
|
|
* 4. "ibyte" for complex (interleaved) 8 bit integers
|
|
|
|
* 4. "short" for 16 bit integers
|
|
|
|
* 5. "cshort" for complex (interleaved) 16 bit integers
|
|
|
|
* 6. "ishort" for complex (interleaved) 16 bit integers
|
|
|
|
* 7. "float" for 32 bit floating point values
|
|
|
|
* 8. "gr_complex" for complex (interleaved) 32 bit floating point values
|
2019-11-04 17:14:50 +00:00
|
|
|
*
|
|
|
|
* \returns A function object with the following prototype:
|
|
|
|
* void convert_fun( void *dest, void *src, int num_items );
|
|
|
|
*
|
|
|
|
*/
|
2019-11-16 17:00:04 +00:00
|
|
|
item_type_converter_t make_vector_converter(const std::string &input_type,
|
|
|
|
const std::string &output_type);
|
2019-11-04 17:14:50 +00:00
|
|
|
|
|
|
|
#endif
|