diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-09-28 12:54:27 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 12:21:32 -0800 |
commit | fcc2e9c602a6103dfd0f75e035f614b177c5dc35 (patch) | |
tree | 8c6162ab134a79f343b8404f1d82b6bd9483d116 /host/include | |
parent | 0c43030e71f4786bf1ba1b7f08abf6b3d019761f (diff) | |
download | uhd-fcc2e9c602a6103dfd0f75e035f614b177c5dc35.tar.gz uhd-fcc2e9c602a6103dfd0f75e035f614b177c5dc35.tar.bz2 uhd-fcc2e9c602a6103dfd0f75e035f614b177c5dc35.zip |
uhd: Replace boost::function with std::function
This is mostly a search-and-replace operation, with few exceptions:
- boost::function has a clear() method. In C++11, this is achieved by
assigning nullptr to the std::function object.
- The empty() method is replaced by std::function's bool() operator
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/convert.hpp | 4 | ||||
-rw-r--r-- | host/include/uhd/device.hpp | 6 | ||||
-rw-r--r-- | host/include/uhd/image_loader.hpp | 4 | ||||
-rw-r--r-- | host/include/uhd/property_tree.hpp | 8 | ||||
-rw-r--r-- | host/include/uhd/property_tree.ipp | 12 | ||||
-rw-r--r-- | host/include/uhd/transport/bounded_buffer.ipp | 4 | ||||
-rw-r--r-- | host/include/uhd/transport/muxed_zero_copy_if.hpp | 4 | ||||
-rw-r--r-- | host/include/uhd/transport/zero_copy_flow_ctrl.hpp | 4 | ||||
-rw-r--r-- | host/include/uhd/utils/gain_group.hpp | 8 | ||||
-rw-r--r-- | host/include/uhd/utils/msg_task.hpp | 8 | ||||
-rw-r--r-- | host/include/uhd/utils/tasks.hpp | 4 |
11 files changed, 35 insertions, 31 deletions
diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp index 4d84fcdaa..b94c46851 100644 --- a/host/include/uhd/convert.hpp +++ b/host/include/uhd/convert.hpp @@ -10,7 +10,7 @@ #include <uhd/config.hpp> #include <uhd/types/ref_vector.hpp> -#include <boost/function.hpp> +#include <functional> #include <boost/operators.hpp> #include <memory> #include <string> @@ -51,7 +51,7 @@ private: }; //! Conversion factory function typedef -typedef boost::function<converter::sptr(void)> function_type; +typedef std::function<converter::sptr(void)> function_type; //! Priority of conversion routines typedef int priority_type; diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index 11bedf216..f4594504d 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -13,7 +13,7 @@ #include <uhd/stream.hpp> #include <uhd/types/device_addr.hpp> #include <uhd/utils/noncopyable.hpp> -#include <boost/function.hpp> +#include <functional> #include <memory> namespace uhd { @@ -28,8 +28,8 @@ class UHD_API device : uhd::noncopyable { public: typedef std::shared_ptr<device> sptr; - typedef boost::function<device_addrs_t(const device_addr_t&)> find_t; - typedef boost::function<sptr(const device_addr_t&)> make_t; + typedef std::function<device_addrs_t(const device_addr_t&)> find_t; + typedef std::function<sptr(const device_addr_t&)> make_t; //! Device type, used as a filter in make enum device_filter_t { ANY, USRP, CLOCK }; diff --git a/host/include/uhd/image_loader.hpp b/host/include/uhd/image_loader.hpp index ba1ab7454..d3f9f5445 100644 --- a/host/include/uhd/image_loader.hpp +++ b/host/include/uhd/image_loader.hpp @@ -12,7 +12,7 @@ #include <uhd/config.hpp> #include <uhd/types/device_addr.hpp> #include <uhd/utils/noncopyable.hpp> -#include <boost/function.hpp> +#include <functional> #include <string> namespace uhd { @@ -50,7 +50,7 @@ public: * device and expect the default image(s) to be loaded, but the specific * model of the device cannot be determined beyond a category. */ - typedef boost::function<bool(const image_loader_args_t&)> loader_fcn_t; + typedef std::function<bool(const image_loader_args_t&)> loader_fcn_t; //! Register an image loader /*! diff --git a/host/include/uhd/property_tree.hpp b/host/include/uhd/property_tree.hpp index 4a839f8e9..9e4bcd57a 100644 --- a/host/include/uhd/property_tree.hpp +++ b/host/include/uhd/property_tree.hpp @@ -11,7 +11,7 @@ #include <uhd/config.hpp> #include <uhd/utils/noncopyable.hpp> -#include <boost/function.hpp> +#include <functional> #include <memory> #include <typeindex> #include <vector> @@ -70,9 +70,9 @@ template <typename T> class property : uhd::noncopyable { public: - typedef boost::function<void(const T&)> subscriber_type; - typedef boost::function<T(void)> publisher_type; - typedef boost::function<T(const T&)> coercer_type; + typedef std::function<void(const T&)> subscriber_type; + typedef std::function<T(void)> publisher_type; + typedef std::function<T(const T&)> coercer_type; virtual ~property<T>(void) = 0; diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp index 73b3c737a..7a4ffd85a 100644 --- a/host/include/uhd/property_tree.ipp +++ b/host/include/uhd/property_tree.ipp @@ -37,8 +37,9 @@ public: property<T>& set_coercer(const typename property<T>::coercer_type& coercer) { - if (not _coercer.empty()) + if (_coercer) { uhd::assertion_error("cannot register more than one coercer for a property"); + } if (_coerce_mode == property_tree::MANUAL_COERCE) uhd::assertion_error( "cannot register coercer for a manually coerced property"); @@ -49,9 +50,10 @@ public: property<T>& set_publisher(const typename property<T>::publisher_type& publisher) { - if (not _publisher.empty()) + if (_publisher) { uhd::assertion_error( "cannot register more than one publisher for a property"); + } _publisher = publisher; return *this; @@ -91,7 +93,7 @@ public: for (typename property<T>::subscriber_type& dsub : _desired_subscribers) { dsub(get_value_ref(_value)); // let errors propagate } - if (not _coercer.empty()) { + if (_coercer) { _set_coerced(_coercer(get_value_ref(_value))); } else { if (_coerce_mode == property_tree::AUTO_COERCE) @@ -113,7 +115,7 @@ public: if (empty()) { throw uhd::runtime_error("Cannot get() on an uninitialized (empty) property"); } - if (not _publisher.empty()) { + if (_publisher) { return _publisher(); } else { if (_coerced_value.get() == NULL @@ -135,7 +137,7 @@ public: bool empty(void) const { - return _publisher.empty() and _value.get() == NULL; + return !bool(_publisher) and _value.get() == NULL; } private: diff --git a/host/include/uhd/transport/bounded_buffer.ipp b/host/include/uhd/transport/bounded_buffer.ipp index 4db182508..d1058756d 100644 --- a/host/include/uhd/transport/bounded_buffer.ipp +++ b/host/include/uhd/transport/bounded_buffer.ipp @@ -12,7 +12,7 @@ #include <uhd/utils/noncopyable.hpp> #include <boost/bind.hpp> #include <boost/utility.hpp> -#include <boost/function.hpp> +#include <functional> #include <boost/circular_buffer.hpp> #include <boost/thread/condition.hpp> #include <boost/thread/locks.hpp> @@ -133,7 +133,7 @@ namespace uhd{ namespace transport{ bool not_full(void) const{return not _buffer.full();} bool not_empty(void) const{return not _buffer.empty();} - boost::function<bool(void)> _not_full_fcn, _not_empty_fcn; + std::function<bool(void)> _not_full_fcn, _not_empty_fcn; /*! * Three part operation to pop an element: diff --git a/host/include/uhd/transport/muxed_zero_copy_if.hpp b/host/include/uhd/transport/muxed_zero_copy_if.hpp index 61086fbba..b2527db10 100644 --- a/host/include/uhd/transport/muxed_zero_copy_if.hpp +++ b/host/include/uhd/transport/muxed_zero_copy_if.hpp @@ -11,7 +11,7 @@ #include <uhd/config.hpp> #include <uhd/transport/zero_copy.hpp> #include <stdint.h> -#include <boost/function.hpp> +#include <functional> #include <uhd/utils/noncopyable.hpp> namespace uhd { namespace transport { @@ -40,7 +40,7 @@ public: * \param size number of bytes in the frame payload * \return stream number */ - typedef boost::function<uint32_t(void* buff, size_t size)> stream_classifier_fn; + typedef std::function<uint32_t(void* buff, size_t size)> stream_classifier_fn; //! virtual dtor virtual ~muxed_zero_copy_if() {} diff --git a/host/include/uhd/transport/zero_copy_flow_ctrl.hpp b/host/include/uhd/transport/zero_copy_flow_ctrl.hpp index f12aed2a9..4028e2e1d 100644 --- a/host/include/uhd/transport/zero_copy_flow_ctrl.hpp +++ b/host/include/uhd/transport/zero_copy_flow_ctrl.hpp @@ -10,7 +10,7 @@ #include <uhd/config.hpp> #include <uhd/transport/zero_copy.hpp> -#include <boost/function.hpp> +#include <functional> #include <memory> namespace uhd { namespace transport { @@ -20,7 +20,7 @@ namespace uhd { namespace transport { * \param buff buffer to be sent or receive buffer being released * \return true if OK, false if not */ -typedef boost::function<bool(managed_buffer::sptr buff)> flow_ctrl_func; +typedef std::function<bool(managed_buffer::sptr buff)> flow_ctrl_func; /*! * Adds flow control to any zero_copy_if transport. diff --git a/host/include/uhd/utils/gain_group.hpp b/host/include/uhd/utils/gain_group.hpp index 8fe69441f..bfc6a94a6 100644 --- a/host/include/uhd/utils/gain_group.hpp +++ b/host/include/uhd/utils/gain_group.hpp @@ -11,7 +11,7 @@ #include <uhd/config.hpp> #include <uhd/types/ranges.hpp> #include <uhd/utils/noncopyable.hpp> -#include <boost/function.hpp> +#include <functional> #include <memory> #include <string> #include <vector> @@ -23,9 +23,9 @@ namespace uhd { */ struct UHD_API gain_fcns_t { - boost::function<gain_range_t(void)> get_range; - boost::function<double(void)> get_value; - boost::function<void(double)> set_value; + std::function<gain_range_t(void)> get_range; + std::function<double(void)> get_value; + std::function<void(double)> set_value; }; class UHD_API gain_group : uhd::noncopyable diff --git a/host/include/uhd/utils/msg_task.hpp b/host/include/uhd/utils/msg_task.hpp index fd08523f7..9b8b5b23d 100644 --- a/host/include/uhd/utils/msg_task.hpp +++ b/host/include/uhd/utils/msg_task.hpp @@ -1,6 +1,7 @@ // // Copyright 2011-2015 Ettus Research LLC // Copyright 2018 Ettus Research, a National Instruments Company +// Copyright 2019 Ettus Research, a National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // @@ -10,11 +11,12 @@ #include <uhd/config.hpp> #include <uhd/transport/zero_copy.hpp> +#include <uhd/utils/noncopyable.hpp> #include <stdint.h> -#include <boost/function.hpp> #include <boost/optional/optional.hpp> +#include <cstring> +#include <functional> #include <memory> -#include <uhd/utils/noncopyable.hpp> #include <vector> namespace uhd { @@ -24,7 +26,7 @@ public: typedef std::shared_ptr<msg_task> sptr; typedef std::vector<uint8_t> msg_payload_t; typedef std::pair<uint32_t, msg_payload_t> msg_type_t; - typedef boost::function<boost::optional<msg_type_t>(void)> task_fcn_type; + typedef std::function<boost::optional<msg_type_t>(void)> task_fcn_type; /* * During shutdown message queues for radio control cores might not be available diff --git a/host/include/uhd/utils/tasks.hpp b/host/include/uhd/utils/tasks.hpp index eaee3edbe..456af25e6 100644 --- a/host/include/uhd/utils/tasks.hpp +++ b/host/include/uhd/utils/tasks.hpp @@ -12,7 +12,7 @@ #include <uhd/config.hpp> #include <uhd/utils/noncopyable.hpp> -#include <boost/function.hpp> +#include <functional> #include <memory> #include <string> @@ -22,7 +22,7 @@ class UHD_API task : uhd::noncopyable { public: typedef std::shared_ptr<task> sptr; - typedef boost::function<void(void)> task_fcn_type; + typedef std::function<void(void)> task_fcn_type; /*! * Create a new task object with function callback. |