root / host / include / uhd / convert.hpp @ 52e20f9e
History | View | Annotate | Download (2.91 KB)
| 1 |
//
|
|---|---|
| 2 |
// Copyright 2011 Ettus Research LLC
|
| 3 |
//
|
| 4 |
// This program is free software: you can redistribute it and/or modify
|
| 5 |
// it under the terms of the GNU General Public License as published by
|
| 6 |
// the Free Software Foundation, either version 3 of the License, or
|
| 7 |
// (at your option) any later version.
|
| 8 |
//
|
| 9 |
// This program is distributed in the hope that it will be useful,
|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
// GNU General Public License for more details.
|
| 13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
//
|
| 17 |
|
| 18 |
#ifndef INCLUDED_UHD_CONVERT_HPP
|
| 19 |
#define INCLUDED_UHD_CONVERT_HPP
|
| 20 |
|
| 21 |
#include <uhd/config.hpp> |
| 22 |
#include <uhd/types/ref_vector.hpp> |
| 23 |
#include <boost/function.hpp> |
| 24 |
#include <boost/operators.hpp> |
| 25 |
#include <string> |
| 26 |
|
| 27 |
namespace uhd{ namespace convert{ |
| 28 |
|
| 29 |
typedef uhd::ref_vector<void *> output_type; |
| 30 |
typedef uhd::ref_vector<const void *> input_type; |
| 31 |
|
| 32 |
//! input vectors, output vectors, num samples, scale factor
|
| 33 |
typedef boost::function<void(const input_type&, const output_type&, const size_t, const double)> function_type; |
| 34 |
|
| 35 |
/*!
|
| 36 |
* Describe the priority of a converter function.
|
| 37 |
* A higher priority function takes precedence.
|
| 38 |
* The general case function are the lowest.
|
| 39 |
* Next comes the liborc implementations.
|
| 40 |
* Custom intrinsics implementations are highest.
|
| 41 |
*/
|
| 42 |
enum priority_type{
|
| 43 |
PRIORITY_GENERAL = 0,
|
| 44 |
PRIORITY_LIBORC = 1,
|
| 45 |
PRIORITY_CUSTOM = 2,
|
| 46 |
PRIORITY_EMPTY = -1,
|
| 47 |
}; |
| 48 |
|
| 49 |
//! Identify a conversion routine in the registry
|
| 50 |
struct id_type : boost::equality_comparable<id_type>{
|
| 51 |
std::string input_markup;
|
| 52 |
size_t num_inputs; |
| 53 |
std::string output_markup;
|
| 54 |
size_t num_outputs; |
| 55 |
std::string args;
|
| 56 |
std::string to_pp_string(void) const; |
| 57 |
}; |
| 58 |
|
| 59 |
//! Implement equality_comparable interface
|
| 60 |
UHD_API bool operator==(const id_type &, const id_type &); |
| 61 |
|
| 62 |
/*!
|
| 63 |
* Register a converter function.
|
| 64 |
* \param id identify the conversion
|
| 65 |
* \param fcn a pointer to the converter
|
| 66 |
* \param prio the function priority
|
| 67 |
*/
|
| 68 |
UHD_API void register_converter(
|
| 69 |
const id_type &id,
|
| 70 |
function_type fcn, |
| 71 |
priority_type prio |
| 72 |
); |
| 73 |
|
| 74 |
/*!
|
| 75 |
* Get a converter function.
|
| 76 |
* \param id identify the conversion
|
| 77 |
* \return the converter function
|
| 78 |
*/
|
| 79 |
UHD_API function_type get_converter(const id_type &id);
|
| 80 |
|
| 81 |
/*!
|
| 82 |
* Register the size of a particular item.
|
| 83 |
* \param markup the item markup
|
| 84 |
* \param size the size in bytes
|
| 85 |
*/
|
| 86 |
UHD_API void register_bytes_per_item(
|
| 87 |
const std::string &markup, const size_t size |
| 88 |
); |
| 89 |
|
| 90 |
//! Convert an item markup to a size in bytes
|
| 91 |
UHD_API size_t get_bytes_per_item(const std::string &markup); |
| 92 |
|
| 93 |
}} //namespace
|
| 94 |
|
| 95 |
#endif /* INCLUDED_UHD_CONVERT_HPP */ |