summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/transport/zero_copy.hpp27
-rw-r--r--host/include/uhd/usrp/dboard_base.hpp4
-rw-r--r--host/include/uhd/utils/CMakeLists.txt1
-rw-r--r--host/include/uhd/utils/pimpl.hpp55
4 files changed, 75 insertions, 12 deletions
diff --git a/host/include/uhd/transport/zero_copy.hpp b/host/include/uhd/transport/zero_copy.hpp
index d6eb89a91..2815e3189 100644
--- a/host/include/uhd/transport/zero_copy.hpp
+++ b/host/include/uhd/transport/zero_copy.hpp
@@ -19,6 +19,7 @@
#define INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP
#include <uhd/config.hpp>
+#include <uhd/utils/pimpl.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
@@ -156,10 +157,14 @@ namespace uhd{ namespace transport{
*/
class UHD_API phony_zero_copy_recv_if : public virtual zero_copy_if{
public:
-
- //! structors
+ /*!
+ * Create a phony zero copy recv interface.
+ * \param max_buff_size max buffer size in bytes
+ */
phony_zero_copy_recv_if(size_t max_buff_size);
- ~phony_zero_copy_recv_if(void);
+
+ //! destructor
+ virtual ~phony_zero_copy_recv_if(void);
/*!
* Get a new receive buffer from this transport object.
@@ -167,7 +172,6 @@ namespace uhd{ namespace transport{
managed_recv_buffer::sptr get_recv_buff(void);
private:
-
/*!
* Perform a private copying recv.
* \param buff the buffer to write data into
@@ -175,7 +179,7 @@ namespace uhd{ namespace transport{
*/
virtual size_t recv(const boost::asio::mutable_buffer &buff) = 0;
- struct impl; impl *_impl; //private implementation details
+ UHD_PIMPL_DECL(impl) _impl;
};
/*!
@@ -186,10 +190,14 @@ namespace uhd{ namespace transport{
*/
class UHD_API phony_zero_copy_send_if : public virtual zero_copy_if{
public:
-
- //! structors
+ /*!
+ * Create a phony zero copy send interface.
+ * \param max_buff_size max buffer size in bytes
+ */
phony_zero_copy_send_if(size_t max_buff_size);
- ~phony_zero_copy_send_if(void);
+
+ //! destructor
+ virtual ~phony_zero_copy_send_if(void);
/*!
* Get a new send buffer from this transport object.
@@ -197,7 +205,6 @@ namespace uhd{ namespace transport{
managed_send_buffer::sptr get_send_buff(void);
private:
-
/*!
* Perform a private copying send.
* \param buff the buffer to read data from
@@ -205,7 +212,7 @@ namespace uhd{ namespace transport{
*/
virtual size_t send(const boost::asio::const_buffer &buff) = 0;
- struct impl; impl *_impl; //private implementation details
+ UHD_PIMPL_DECL(impl) _impl;
};
}} //namespace
diff --git a/host/include/uhd/usrp/dboard_base.hpp b/host/include/uhd/usrp/dboard_base.hpp
index 28bf2ae66..e88d39876 100644
--- a/host/include/uhd/usrp/dboard_base.hpp
+++ b/host/include/uhd/usrp/dboard_base.hpp
@@ -20,6 +20,7 @@
#include <uhd/config.hpp>
#include <uhd/wax.hpp>
+#include <uhd/utils/pimpl.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include <uhd/usrp/dboard_id.hpp>
@@ -58,8 +59,7 @@ protected:
dboard_id_t get_tx_id(void);
private:
- struct dboard_base_impl;
- dboard_base_impl *_impl;
+ UHD_PIMPL_DECL(impl) _impl;
};
/*!
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt
index f588c6310..391e684c8 100644
--- a/host/include/uhd/utils/CMakeLists.txt
+++ b/host/include/uhd/utils/CMakeLists.txt
@@ -20,6 +20,7 @@ INSTALL(FILES
assert.hpp
exception.hpp
gain_handler.hpp
+ pimpl.hpp
props.hpp
safe_main.hpp
static.hpp
diff --git a/host/include/uhd/utils/pimpl.hpp b/host/include/uhd/utils/pimpl.hpp
new file mode 100644
index 000000000..09bf0c0a2
--- /dev/null
+++ b/host/include/uhd/utils/pimpl.hpp
@@ -0,0 +1,55 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_PIMPL_HPP
+#define INCLUDED_UHD_UTILS_PIMPL_HPP
+
+#include <uhd/config.hpp>
+#include <boost/shared_ptr.hpp>
+
+/*! \file pimpl.hpp
+ * "Pimpl idiom" (pointer to implementation idiom).
+ * The UHD_PIMPL_* macros simplify code overhead for declaring and making pimpls.
+ *
+ * Each pimpl is implemented as a shared pointer to the implementation:
+ * - The container class will not have to deallocate the pimpl.
+ * - The container class will use the pimpl as a regular pointer.
+ * - Usage: _impl->method(arg0, arg1)
+ * - Usage: _impl->member = value;
+ *
+ * \see http://en.wikipedia.org/wiki/Opaque_pointer
+ */
+
+/*!
+ * Make a declaration for a pimpl in a header file.
+ * - Usage: UHD_PIMPL_DECL(impl) _impl;
+ * \param _name the name of the pimpl class
+ */
+#define UHD_PIMPL_DECL(_name) \
+ struct _name; boost::shared_ptr<_name>
+
+/*!
+ * Make an instance of a pimpl in a source file.
+ * - Usage: _impl = UHD_PIMPL_MAKE(impl, ());
+ * - Usage: _impl = UHD_PIMPL_MAKE(impl, (a0, a1));
+ * \param _name the name of the pimpl class
+ * \param _args the constructor args for the pimpl
+ */
+#define UHD_PIMPL_MAKE(_name, _args) \
+ boost::shared_ptr<_name>(new _name _args)
+
+#endif /* INCLUDED_UHD_UTILS_PIMPL_HPP */