UHD 003.005.002-0-unknown

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
convert.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011-2012 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/shared_ptr.hpp>
24 #include <boost/function.hpp>
25 #include <boost/operators.hpp>
26 #include <string>
27
28 namespace uhd{ namespace convert{
29
31 class converter{
32 public:
33 typedef boost::shared_ptr<converter> sptr;
34 typedef uhd::ref_vector<void *> output_type;
35 typedef uhd::ref_vector<const void *> input_type;
36
38 virtual void set_scalar(const double) = 0;
39
41 UHD_INLINE void conv(const input_type &in, const output_type &out, const size_t num){
42 if (num != 0) (*this)(in, out, num);
43 }
44
45 private:
47 virtual void operator()(const input_type&, const output_type&, const size_t) = 0;
48 };
49
51 typedef boost::function<converter::sptr(void)> function_type;
52
54 typedef int priority_type;
55
57 struct id_type : boost::equality_comparable<id_type>{
58 std::string input_format;
59 size_t num_inputs;
60 std::string output_format;
61 size_t num_outputs;
62 std::string to_pp_string(void) const;
63 };
64
66 UHD_API bool operator==(const id_type &, const id_type &);
67
74 UHD_API void register_converter(
75 const id_type &id,
76 const function_type &fcn,
77 const priority_type prio
78 );
79
86 UHD_API function_type get_converter(
87 const id_type &id,
88 const priority_type prio = -1
89 );
90
96 UHD_API void register_bytes_per_item(
97 const std::string &format, const size_t size
98 );
99
101 UHD_API size_t get_bytes_per_item(const std::string &format);
102
103 }} //namespace
104
105 #endif /* INCLUDED_UHD_CONVERT_HPP */
uhd::convert::get_converter
UHD_API function_type get_converter(const id_type &id, const priority_type prio=-1)
ref_vector.hpp
uhd::convert::id_type
Identify a conversion routine in the registry.
Definition: convert.hpp:57
uhd::convert::register_bytes_per_item
UHD_API void register_bytes_per_item(const std::string &format, const size_t size)
uhd::convert::function_type
boost::function< converter::sptr(void)> function_type
Conversion factory function typedef.
Definition: convert.hpp:51
uhd::convert::converter::set_scalar
virtual void set_scalar(const double)=0
Set the scale factor (used in floating point conversions)
uhd::convert::get_bytes_per_item
UHD_API size_t get_bytes_per_item(const std::string &format)
Convert an item format to a size in bytes.
uhd::convert::converter::input_type
uhd::ref_vector< const void * > input_type
Definition: convert.hpp:35
config.hpp
uhd::convert::operator==
UHD_API bool operator==(const id_type &, const id_type &)
Implement equality_comparable interface.
uhd::convert::converter
A conversion class that implements a conversion from inputs -&gt; outputs.
Definition: convert.hpp:31
UHD_API
#define UHD_API
Definition: config.hpp:76
uhd::convert::id_type::output_format
std::string output_format
Definition: convert.hpp:60
UHD_INLINE
#define UHD_INLINE
Definition: config.hpp:67
uhd::convert::converter::conv
UHD_INLINE void conv(const input_type &in, const output_type &out, const size_t num)
The public conversion method to convert inputs -&gt; outputs.
Definition: convert.hpp:41
uhd::ref_vector
Definition: ref_vector.hpp:30
uhd::convert::priority_type
int priority_type
Priority of conversion routines.
Definition: convert.hpp:54
uhd::convert::id_type::num_inputs
size_t num_inputs
Definition: convert.hpp:59
uhd::convert::register_converter
UHD_API void register_converter(const id_type &id, const function_type &fcn, const priority_type prio)
uhd::convert::converter::output_type
uhd::ref_vector< void * > output_type
Definition: convert.hpp:34
uhd::convert::id_type::to_pp_string
std::string to_pp_string(void) const
uhd::convert::id_type::num_outputs
size_t num_outputs
Definition: convert.hpp:61
uhd::convert::converter::sptr
boost::shared_ptr< converter > sptr
Definition: convert.hpp:33
uhd::convert::id_type::input_format
std::string input_format
Definition: convert.hpp:58