UHD  003.000.c6c4b01e0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
zero_copy.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_TRANSPORT_ZERO_COPY_HPP
19 #define INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP
20 
21 #include <uhd/config.hpp>
22 #include <boost/utility.hpp>
23 #include <boost/shared_ptr.hpp>
24 
25 namespace uhd{ namespace transport{
26 
33  public:
34  typedef boost::shared_ptr<managed_recv_buffer> sptr;
35 
41  virtual void release(void) = 0;
42 
47  template <class T> inline T cast(void) const{
48  return static_cast<T>(this->get_buff());
49  }
50 
55  inline size_t size(void) const{
56  return this->get_size();
57  }
58 
59  private:
60  virtual const void *get_buff(void) const = 0;
61  virtual size_t get_size(void) const = 0;
62  };
63 
70  public:
71  typedef boost::shared_ptr<managed_send_buffer> sptr;
72 
79  virtual void commit(size_t num_bytes) = 0;
80 
85  template <class T> inline T cast(void) const{
86  return static_cast<T>(this->get_buff());
87  }
88 
93  inline size_t size(void) const{
94  return this->get_size();
95  }
96 
97  private:
98  virtual void *get_buff(void) const = 0;
99  virtual size_t get_size(void) const = 0;
100  };
101 
107  class UHD_API zero_copy_if : boost::noncopyable{
108  public:
109  typedef boost::shared_ptr<zero_copy_if> sptr;
110 
116  virtual managed_recv_buffer::sptr get_recv_buff(double timeout = 0.1) = 0;
117 
123  virtual size_t get_num_recv_frames(void) const = 0;
124 
130  virtual size_t get_recv_frame_size(void) const = 0;
131 
137  virtual managed_send_buffer::sptr get_send_buff(double timeout = 0.1) = 0;
138 
144  virtual size_t get_num_send_frames(void) const = 0;
145 
151  virtual size_t get_send_frame_size(void) const = 0;
152 
153  };
154 
155 }} //namespace
156 
157 #endif /* INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP */
size_t size(void) const
Definition: zero_copy.hpp:55
size_t size(void) const
Definition: zero_copy.hpp:93
boost::shared_ptr< zero_copy_if > sptr
Definition: zero_copy.hpp:109
boost::shared_ptr< managed_recv_buffer > sptr
Definition: zero_copy.hpp:34
Definition: zero_copy.hpp:69
#define UHD_API
Definition: config.hpp:76
Definition: convert.hpp:28
Definition: zero_copy.hpp:32
Definition: zero_copy.hpp:107
T cast(void) const
Definition: zero_copy.hpp:85
T cast(void) const
Definition: zero_copy.hpp:47
boost::shared_ptr< managed_send_buffer > sptr
Definition: zero_copy.hpp:71