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/examples/rfnoc_rx_to_file.cpp | 2 +- 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 ++-- host/lib/convert/gen_convert_general.py | 1 + host/lib/experts/expert_container.cpp | 2 +- host/lib/include/uhdlib/experts/expert_nodes.hpp | 12 ++++++------ host/lib/include/uhdlib/usrp/common/adf435x.hpp | 4 ++-- host/lib/include/uhdlib/usrp/common/adf535x.hpp | 2 +- host/lib/include/uhdlib/usrp/common/lmx2592.hpp | 2 +- host/lib/include/uhdlib/usrp/common/max287x.hpp | 4 ++-- host/lib/include/uhdlib/utils/ihex.hpp | 4 ++-- host/lib/transport/libusb1_zero_copy.cpp | 6 +++--- host/lib/transport/super_recv_packet_handler.hpp | 12 ++++++------ host/lib/transport/super_send_packet_handler.hpp | 2 +- host/lib/usrp/usrp1/io_impl.cpp | 8 ++++---- host/lib/usrp/usrp1/soft_time_ctrl.hpp | 4 ++-- host/lib/usrp/usrp2/io_impl.cpp | 2 +- host/lib/usrp/usrp2/usrp2_iface.hpp | 2 +- host/lib/usrp/usrp2/usrp2_impl.hpp | 2 +- 28 files changed, 71 insertions(+), 66 deletions(-) (limited to 'host') diff --git a/host/examples/rfnoc_rx_to_file.cpp b/host/examples/rfnoc_rx_to_file.cpp index 7908b2ef6..2211831aa 100644 --- a/host/examples/rfnoc_rx_to_file.cpp +++ b/host/examples/rfnoc_rx_to_file.cpp @@ -176,7 +176,7 @@ void recv_to_file(uhd::rx_streamer::sptr rx_stream, } } -typedef boost::function get_sensor_fn_t; +typedef std::function get_sensor_fn_t; bool check_locked_sensor(std::vector sensor_names, const char* sensor_name, 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. diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py index 1b1106d4c..19d699cd2 100644 --- a/host/lib/convert/gen_convert_general.py +++ b/host/lib/convert/gen_convert_general.py @@ -20,6 +20,7 @@ TMPL_HEADER = """ #include "convert_common.hpp" #include #include +#include using namespace uhd::convert; diff --git a/host/lib/experts/expert_container.cpp b/host/lib/experts/expert_container.cpp index 33412cb6f..3a1e54ae4 100644 --- a/host/lib/experts/expert_container.cpp +++ b/host/lib/experts/expert_container.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/host/lib/include/uhdlib/experts/expert_nodes.hpp b/host/lib/include/uhdlib/experts/expert_nodes.hpp index d1f38ac07..665c0e579 100644 --- a/host/lib/include/uhdlib/experts/expert_nodes.hpp +++ b/host/lib/include/uhdlib/experts/expert_nodes.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -36,7 +36,7 @@ namespace uhd { namespace experts { */ class dag_vertex_t : private uhd::noncopyable { public: - typedef boost::function callback_func_t; + typedef std::function callback_func_t; virtual ~dag_vertex_t() {} @@ -195,11 +195,11 @@ namespace uhd { namespace experts { } virtual bool has_write_callback() const { - return not _wr_callback.empty(); + return bool(_wr_callback); } virtual void clear_write_callback() { - _wr_callback.clear(); + _wr_callback = nullptr; } virtual void set_read_callback(const callback_func_t& func) { @@ -207,11 +207,11 @@ namespace uhd { namespace experts { } virtual bool has_read_callback() const { - return not _rd_callback.empty(); + return bool(_rd_callback); } virtual void clear_read_callback() { - _rd_callback.clear(); + _rd_callback = nullptr; } boost::recursive_mutex* _callback_mutex; diff --git a/host/lib/include/uhdlib/usrp/common/adf435x.hpp b/host/lib/include/uhdlib/usrp/common/adf435x.hpp index 6f654bcbb..886c8d335 100644 --- a/host/lib/include/uhdlib/usrp/common/adf435x.hpp +++ b/host/lib/include/uhdlib/usrp/common/adf435x.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -24,7 +24,7 @@ class adf435x_iface { public: typedef std::shared_ptr sptr; - typedef boost::function)> write_fn_t; + typedef std::function)> write_fn_t; static sptr make_adf4350(write_fn_t write); static sptr make_adf4351(write_fn_t write); diff --git a/host/lib/include/uhdlib/usrp/common/adf535x.hpp b/host/lib/include/uhdlib/usrp/common/adf535x.hpp index bc3c445bb..c42f05b57 100644 --- a/host/lib/include/uhdlib/usrp/common/adf535x.hpp +++ b/host/lib/include/uhdlib/usrp/common/adf535x.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/host/lib/include/uhdlib/usrp/common/lmx2592.hpp b/host/lib/include/uhdlib/usrp/common/lmx2592.hpp index a754fa63d..9ee3f944f 100644 --- a/host/lib/include/uhdlib/usrp/common/lmx2592.hpp +++ b/host/lib/include/uhdlib/usrp/common/lmx2592.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/host/lib/include/uhdlib/usrp/common/max287x.hpp b/host/lib/include/uhdlib/usrp/common/max287x.hpp index 51c22c5d8..08ee5b16d 100644 --- a/host/lib/include/uhdlib/usrp/common/max287x.hpp +++ b/host/lib/include/uhdlib/usrp/common/max287x.hpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ class max287x_iface public: typedef std::shared_ptr sptr; - typedef boost::function)> write_fn; + typedef std::function)> write_fn; /** * LD Pin Modes diff --git a/host/lib/include/uhdlib/utils/ihex.hpp b/host/lib/include/uhdlib/utils/ihex.hpp index 4b1be77f1..9cb204280 100644 --- a/host/lib/include/uhdlib/utils/ihex.hpp +++ b/host/lib/include/uhdlib/utils/ihex.hpp @@ -9,7 +9,7 @@ #define INCLUDED_IHEX_READER_HPP #include -#include +#include #include #include #include @@ -20,7 +20,7 @@ class ihex_reader { public: // Arguments are: lower address bits, upper address bits, buff, length - typedef boost::function record_handle_type; + typedef std::function record_handle_type; /* * \param ihex_filename Path to the *.ihx file diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index fbeddbcdd..356d247cb 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -115,7 +115,7 @@ class libusb_zero_copy_mb : public managed_buffer public: libusb_zero_copy_mb(libusb_transfer* lut, const size_t frame_size, - boost::function release_cb, + std::function release_cb, const bool is_recv, const std::string& name) : _release_cb(release_cb) @@ -192,7 +192,7 @@ public: } private: - boost::function _release_cb; + std::function _release_cb; const bool _is_recv; const std::string _name; libusb_context* _ctx; diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp index a09281459..b19b50b38 100644 --- a/host/lib/transport/super_recv_packet_handler.hpp +++ b/host/lib/transport/super_recv_packet_handler.hpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -36,7 +36,7 @@ UHD_INLINE uint32_t get_context_code( return word0 & 0xff; } -typedef boost::function handle_overflow_type; +typedef std::function handle_overflow_type; static inline void handle_overflow_nop(void) {} /*********************************************************************** @@ -49,12 +49,12 @@ static inline void handle_overflow_nop(void) {} class recv_packet_handler { public: - typedef boost::function get_buff_type; - typedef boost::function handle_flowctrl_type; + typedef std::function get_buff_type; + typedef std::function handle_flowctrl_type; typedef std::function handle_flowctrl_ack_type; - typedef boost::function issue_stream_cmd_type; + typedef std::function issue_stream_cmd_type; typedef void (*vrt_unpacker_type)(const uint32_t*, vrt::if_packet_info_t&); - // typedef boost::function + // typedef std::function // vrt_unpacker_type; /*! diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp index 40ca2e414..21f7357c3 100644 --- a/host/lib/transport/super_send_packet_handler.hpp +++ b/host/lib/transport/super_send_packet_handler.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index 3d45824e4..462f330e6 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -76,7 +76,7 @@ struct offset_send_buffer{ **********************************************************************/ class offset_managed_send_buffer : public managed_send_buffer{ public: - typedef boost::function commit_cb_type; + typedef std::function commit_cb_type; offset_managed_send_buffer(const commit_cb_type &commit_cb): _commit_cb(commit_cb) { @@ -366,7 +366,7 @@ private: **********************************************************************/ class usrp1_send_packet_streamer : public sph::send_packet_handler, public tx_streamer{ public: - usrp1_send_packet_streamer(const size_t max_num_samps, soft_time_ctrl::sptr stc, boost::function tx_enb_fcn){ + usrp1_send_packet_streamer(const size_t max_num_samps, soft_time_ctrl::sptr stc, std::function tx_enb_fcn){ _max_num_samps = max_num_samps; this->set_max_samples_per_packet(_max_num_samps); _stc = stc; @@ -419,7 +419,7 @@ public: private: size_t _max_num_samps; soft_time_ctrl::sptr _stc; - boost::function _tx_enb_fcn; + std::function _tx_enb_fcn; }; /*********************************************************************** @@ -687,7 +687,7 @@ tx_streamer::sptr usrp1_impl::get_tx_stream(const uhd::stream_args_t &args_){ const size_t spp = bpp/convert::get_bytes_per_item(args.otw_format); //make the new streamer given the samples per packet - boost::function tx_fcn = boost::bind(&usrp1_impl::tx_stream_on_off, this, _1); + std::function tx_fcn = boost::bind(&usrp1_impl::tx_stream_on_off, this, _1); std::shared_ptr my_streamer = std::make_shared(spp, _soft_time_ctrl, tx_fcn); diff --git a/host/lib/usrp/usrp1/soft_time_ctrl.hpp b/host/lib/usrp/usrp1/soft_time_ctrl.hpp index 9143b6af2..48915499a 100644 --- a/host/lib/usrp/usrp1/soft_time_ctrl.hpp +++ b/host/lib/usrp/usrp1/soft_time_ctrl.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace uhd{ namespace usrp{ @@ -28,7 +28,7 @@ namespace uhd{ namespace usrp{ class soft_time_ctrl : uhd::noncopyable{ public: typedef std::shared_ptr sptr; - typedef boost::function cb_fcn_type; + typedef std::function cb_fcn_type; virtual ~soft_time_ctrl(void) = 0; diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index d965b4e24..efc0644db 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -113,7 +113,7 @@ private: boost::condition _fc_cond; seq_type _last_seq_out, _last_seq_ack; const seq_type _max_seqs_out; - boost::function _ready_fcn; + std::function _ready_fcn; }; /*********************************************************************** diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp index 2752d1a28..b602dab53 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.hpp +++ b/host/lib/usrp/usrp2/usrp2_iface.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include "usrp2_regs.hpp" #include #include diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index 14a3ae8d6..9e4e507de 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include static const double USRP2_LINK_RATE_BPS = 1000e6/8; -- cgit v1.2.3