UHD  003.001.002
device.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-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_DEVICE_HPP
19 #define INCLUDED_UHD_DEVICE_HPP
20 
21 #include <uhd/config.hpp>
23 #include <uhd/types/metadata.hpp>
24 #include <uhd/types/io_type.hpp>
25 #include <uhd/types/ref_vector.hpp>
26 #include <uhd/wax.hpp>
27 #include <boost/utility.hpp>
28 #include <boost/shared_ptr.hpp>
29 #include <boost/function.hpp>
30 
31 namespace uhd{
32 
37 class UHD_API device : boost::noncopyable, public wax::obj{
38 
39 public:
40  typedef boost::shared_ptr<device> sptr;
41  typedef boost::function<device_addrs_t(const device_addr_t &)> find_t;
42  typedef boost::function<sptr(const device_addr_t &)> make_t;
43 
50  static void register_device(
51  const find_t &find,
52  const make_t &make
53  );
54 
64  static device_addrs_t find(const device_addr_t &hint);
65 
77  static sptr make(const device_addr_t &hint, size_t which = 0);
78 
84  SEND_MODE_FULL_BUFF = 0,
86  SEND_MODE_ONE_PACKET = 1
87  };
88 
94  RECV_MODE_FULL_BUFF = 0,
96  RECV_MODE_ONE_PACKET = 1
97  };
98 
101 
104 
129  virtual size_t send(
130  const send_buffs_type &buffs,
131  size_t nsamps_per_buff,
132  const tx_metadata_t &metadata,
133  const io_type_t &io_type,
134  send_mode_t send_mode,
135  double timeout = 0.1
136  ) = 0;
137 
169  virtual size_t recv(
170  const recv_buffs_type &buffs,
171  size_t nsamps_per_buff,
172  rx_metadata_t &metadata,
173  const io_type_t &io_type,
174  recv_mode_t recv_mode,
175  double timeout = 0.1
176  ) = 0;
177 
182  virtual size_t get_max_send_samps_per_packet(void) const = 0;
183 
188  virtual size_t get_max_recv_samps_per_packet(void) const = 0;
189 
196  virtual bool recv_async_msg(
197  async_metadata_t &async_metadata, double timeout = 0.1
198  ) = 0;
199 
200 };
201 
202 } //namespace uhd
203 
204 #endif /* INCLUDED_UHD_DEVICE_HPP */
send_mode_t
Definition: device.hpp:82
recv_mode_t
Definition: device.hpp:92
boost::shared_ptr< device > sptr
Definition: device.hpp:40
Definition: metadata.hpp:31
Definition: metadata.hpp:96
#define UHD_API
Definition: config.hpp:76
Definition: convert.hpp:28
Definition: ref_vector.hpp:30
ref_vector< void * > recv_buffs_type
Typedef for a pointer to a single, or a collection of recv buffers.
Definition: device.hpp:103
Definition: wax.hpp:64
std::vector< device_addr_t > device_addrs_t
A typedef for a vector of device addresses.
Definition: device_addr.hpp:88
boost::function< sptr(const device_addr_t &)> make_t
Definition: device.hpp:42
ref_vector< const void * > send_buffs_type
Typedef for a pointer to a single, or a collection of send buffers.
Definition: device.hpp:100
Definition: metadata.hpp:123
Definition: io_type.hpp:29
Definition: device.hpp:37
boost::function< device_addrs_t(const device_addr_t &)> find_t
Definition: device.hpp:41
Definition: device_addr.hpp:47