UHD  003.005.000-62-stable
include/uhd/convert.hpp
Go to the documentation of this file.
00001 //
00002 // Copyright 2011-2012 Ettus Research LLC
00003 //
00004 // This program is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef INCLUDED_UHD_CONVERT_HPP
00019 #define INCLUDED_UHD_CONVERT_HPP
00020 
00021 #include <uhd/config.hpp>
00022 #include <uhd/types/ref_vector.hpp>
00023 #include <boost/shared_ptr.hpp>
00024 #include <boost/function.hpp>
00025 #include <boost/operators.hpp>
00026 #include <string>
00027 
00028 namespace uhd{ namespace convert{
00029 
00031     class converter{
00032     public:
00033         typedef boost::shared_ptr<converter> sptr;
00034         typedef uhd::ref_vector<void *> output_type;
00035         typedef uhd::ref_vector<const void *> input_type;
00036 
00038         virtual void set_scalar(const double) = 0;
00039 
00041         UHD_INLINE void conv(const input_type &in, const output_type &out, const size_t num){
00042             if (num != 0) (*this)(in, out, num);
00043         }
00044 
00045     private:
00047         virtual void operator()(const input_type&, const output_type&, const size_t) = 0;
00048     };
00049 
00051     typedef boost::function<converter::sptr(void)> function_type;
00052 
00054     typedef int priority_type;
00055 
00057     struct id_type : boost::equality_comparable<id_type>{
00058         std::string input_format;
00059         size_t num_inputs;
00060         std::string output_format;
00061         size_t num_outputs;
00062         std::string to_pp_string(void) const;
00063     };
00064 
00066     UHD_API bool operator==(const id_type &, const id_type &);
00067 
00074     UHD_API void register_converter(
00075         const id_type &id,
00076         const function_type &fcn,
00077         const priority_type prio
00078     );
00079 
00086     UHD_API function_type get_converter(
00087         const id_type &id,
00088         const priority_type prio = -1
00089     );
00090 
00096     UHD_API void register_bytes_per_item(
00097         const std::string &format, const size_t size
00098     );
00099 
00101     UHD_API size_t get_bytes_per_item(const std::string &format);
00102 
00103 }} //namespace
00104 
00105 #endif /* INCLUDED_UHD_CONVERT_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines