From fcc2e9c602a6103dfd0f75e035f614b177c5dc35 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 28 Sep 2019 12:54:27 +0200 Subject: 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 --- host/include/uhd/convert.hpp | 4 ++-- host/include/uhd/device.hpp | 6 +++--- host/include/uhd/image_loader.hpp | 4 ++-- host/include/uhd/property_tree.hpp | 8 ++++---- host/include/uhd/property_tree.ipp | 12 +++++++----- host/include/uhd/transport/bounded_buffer.ipp | 4 ++-- host/include/uhd/transport/muxed_zero_copy_if.hpp | 4 ++-- host/include/uhd/transport/zero_copy_flow_ctrl.hpp | 4 ++-- host/include/uhd/utils/gain_group.hpp | 8 ++++---- host/include/uhd/utils/msg_task.hpp | 8 +++++--- host/include/uhd/utils/tasks.hpp | 4 ++-- 11 files changed, 35 insertions(+), 31 deletions(-) (limited to 'host/include') 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 #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ private: }; //! Conversion factory function typedef -typedef boost::function function_type; +typedef std::function 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 #include #include -#include +#include #include namespace uhd { @@ -28,8 +28,8 @@ class UHD_API device : uhd::noncopyable { public: typedef std::shared_ptr sptr; - typedef boost::function find_t; - typedef boost::function make_t; + typedef std::function find_t; + typedef std::function 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 #include #include -#include +#include #include 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 loader_fcn_t; + typedef std::function 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 #include -#include +#include #include #include #include @@ -70,9 +70,9 @@ template class property : uhd::noncopyable { public: - typedef boost::function subscriber_type; - typedef boost::function publisher_type; - typedef boost::function coercer_type; + typedef std::function subscriber_type; + typedef std::function publisher_type; + typedef std::function coercer_type; virtual ~property(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& set_coercer(const typename property::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& set_publisher(const typename property::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::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 #include #include -#include +#include #include #include #include @@ -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 _not_full_fcn, _not_empty_fcn; + std::function _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 #include #include -#include +#include #include namespace uhd { namespace transport { @@ -40,7 +40,7 @@ public: * \param size number of bytes in the frame payload * \return stream number */ - typedef boost::function stream_classifier_fn; + typedef std::function 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 #include -#include +#include #include 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 flow_ctrl_func; +typedef std::function 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 #include #include -#include +#include #include #include #include @@ -23,9 +23,9 @@ namespace uhd { */ struct UHD_API gain_fcns_t { - boost::function get_range; - boost::function get_value; - boost::function set_value; + std::function get_range; + std::function get_value; + std::function 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 #include +#include #include -#include #include +#include +#include #include -#include #include namespace uhd { @@ -24,7 +26,7 @@ public: typedef std::shared_ptr sptr; typedef std::vector msg_payload_t; typedef std::pair msg_type_t; - typedef boost::function(void)> task_fcn_type; + typedef std::function(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 #include -#include +#include #include #include @@ -22,7 +22,7 @@ class UHD_API task : uhd::noncopyable { public: typedef std::shared_ptr sptr; - typedef boost::function task_fcn_type; + typedef std::function task_fcn_type; /*! * Create a new task object with function callback. -- cgit v1.2.3