UHD 003.002.003

include/uhd/device.hpp

Go to the documentation of this file.
00001 //
00002 // Copyright 2010-2011 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_DEVICE_HPP
00019 #define INCLUDED_UHD_DEVICE_HPP
00020 
00021 #include <uhd/config.hpp>
00022 #include <uhd/types/device_addr.hpp>
00023 #include <uhd/types/metadata.hpp>
00024 #include <uhd/types/io_type.hpp>
00025 #include <uhd/types/ref_vector.hpp>
00026 #include <uhd/wax.hpp>
00027 #include <boost/utility.hpp>
00028 #include <boost/shared_ptr.hpp>
00029 #include <boost/function.hpp>
00030 
00031 namespace uhd{
00032 
00033 class property_tree; //forward declaration
00034 
00039 class UHD_API device : boost::noncopyable, public wax::obj{
00040 
00041 public:
00042     typedef boost::shared_ptr<device> sptr;
00043     typedef boost::function<device_addrs_t(const device_addr_t &)> find_t;
00044     typedef boost::function<sptr(const device_addr_t &)> make_t;
00045 
00052     static void register_device(
00053         const find_t &find,
00054         const make_t &make
00055     );
00056 
00066     static device_addrs_t find(const device_addr_t &hint);
00067 
00079     static sptr make(const device_addr_t &hint, size_t which = 0);
00080 
00084     enum send_mode_t{
00086         SEND_MODE_FULL_BUFF = 0,
00088         SEND_MODE_ONE_PACKET = 1
00089     };
00090 
00094     enum recv_mode_t{
00096         RECV_MODE_FULL_BUFF = 0,
00098         RECV_MODE_ONE_PACKET = 1
00099     };
00100 
00102     typedef ref_vector<const void *> send_buffs_type;
00103 
00105     typedef ref_vector<void *> recv_buffs_type;
00106 
00131     virtual size_t send(
00132         const send_buffs_type &buffs,
00133         size_t nsamps_per_buff,
00134         const tx_metadata_t &metadata,
00135         const io_type_t &io_type,
00136         send_mode_t send_mode,
00137         double timeout = 0.1
00138     ) = 0;
00139 
00171     virtual size_t recv(
00172         const recv_buffs_type &buffs,
00173         size_t nsamps_per_buff,
00174         rx_metadata_t &metadata,
00175         const io_type_t &io_type,
00176         recv_mode_t recv_mode,
00177         double timeout = 0.1
00178     ) = 0;
00179 
00184     virtual size_t get_max_send_samps_per_packet(void) const = 0;
00185 
00190     virtual size_t get_max_recv_samps_per_packet(void) const = 0;
00191 
00198     virtual bool recv_async_msg(
00199         async_metadata_t &async_metadata, double timeout = 0.1
00200     ) = 0;
00201 
00203     virtual boost::shared_ptr<property_tree> get_tree(void) const = 0;
00204 
00205 };
00206 
00207 } //namespace uhd
00208 
00209 #endif /* INCLUDED_UHD_DEVICE_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines