UHD 003.000.001

include/uhd/transport/zero_copy.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_TRANSPORT_ZERO_COPY_HPP
00019 #define INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP
00020 
00021 #include <uhd/config.hpp>
00022 #include <boost/utility.hpp>
00023 #include <boost/shared_ptr.hpp>
00024 
00025 namespace uhd{ namespace transport{
00026 
00032     class UHD_API managed_recv_buffer{
00033     public:
00034         typedef boost::shared_ptr<managed_recv_buffer> sptr;
00035 
00041         virtual void release(void) = 0;
00042 
00047         template <class T> inline T cast(void) const{
00048             return static_cast<T>(this->get_buff());
00049         }
00050 
00055         inline size_t size(void) const{
00056             return this->get_size();
00057         }
00058 
00059     private:
00060         virtual const void *get_buff(void) const = 0;
00061         virtual size_t get_size(void) const = 0;
00062     };
00063 
00069     class UHD_API managed_send_buffer{
00070     public:
00071         typedef boost::shared_ptr<managed_send_buffer> sptr;
00072 
00079         virtual void commit(size_t num_bytes) = 0;
00080 
00085         template <class T> inline T cast(void) const{
00086             return static_cast<T>(this->get_buff());
00087         }
00088 
00093         inline size_t size(void) const{
00094             return this->get_size();
00095         }
00096 
00097     private:
00098         virtual void *get_buff(void) const = 0;
00099         virtual size_t get_size(void) const = 0;
00100     };
00101 
00107     class UHD_API zero_copy_if : boost::noncopyable{
00108     public:
00109         typedef boost::shared_ptr<zero_copy_if> sptr;
00110 
00116         virtual managed_recv_buffer::sptr get_recv_buff(double timeout = 0.1) = 0;
00117 
00123         virtual size_t get_num_recv_frames(void) const = 0;
00124 
00130         virtual size_t get_recv_frame_size(void) const = 0;
00131 
00137         virtual managed_send_buffer::sptr get_send_buff(double timeout = 0.1) = 0;
00138 
00144         virtual size_t get_num_send_frames(void) const = 0;
00145 
00151         virtual size_t get_send_frame_size(void) const = 0;
00152 
00153     };
00154 
00155 }} //namespace
00156 
00157 #endif /* INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines