diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-09-28 11:18:57 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 12:21:32 -0800 |
commit | 1fe98e8701dd0b790b172762c3629db32956d1fc (patch) | |
tree | 7719e69633f9639f1dcdcf00ebf7db6c4cd6dda2 /host/lib/usrp/b200 | |
parent | 8541a9b397fb53034c37dd00289aa96def24d410 (diff) | |
download | uhd-1fe98e8701dd0b790b172762c3629db32956d1fc.tar.gz uhd-1fe98e8701dd0b790b172762c3629db32956d1fc.tar.bz2 uhd-1fe98e8701dd0b790b172762c3629db32956d1fc.zip |
uhd: Replace usage of boost smart pointers with C++11 counterparts
This removes the following Boost constructs:
- boost::shared_ptr, boost::weak_ptr
- boost::enable_shared_from_this
- boost::static_pointer_cast, boost::dynamic_pointer_cast
The appropriate includes were also removed. All C++11 versions of these
require #include <memory>.
Note that the stdlib and Boost versions have the exact same syntax, they
only differ in the namespace (boost vs. std). The modifications were all
done using sed, with the exception of boost::scoped_ptr, which was
replaced by std::unique_ptr.
References to boost::smart_ptr were also removed.
boost::intrusive_ptr is not removed in this commit, since it does not
have a 1:1 mapping to a C++11 construct.
Diffstat (limited to 'host/lib/usrp/b200')
-rw-r--r-- | host/lib/usrp/b200/b200_cores.hpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_iface.hpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 11 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_impl.hpp | 22 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_io_impl.cpp | 40 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_uart.hpp | 4 |
6 files changed, 43 insertions, 44 deletions
diff --git a/host/lib/usrp/b200/b200_cores.hpp b/host/lib/usrp/b200/b200_cores.hpp index 7dabb66e9..324938a73 100644 --- a/host/lib/usrp/b200/b200_cores.hpp +++ b/host/lib/usrp/b200/b200_cores.hpp @@ -12,13 +12,13 @@ #include <uhd/utils/noncopyable.hpp> #include <uhdlib/usrp/cores/spi_core_3000.hpp> #include <uhdlib/usrp/common/adf4001_ctrl.hpp> -#include <boost/shared_ptr.hpp> +#include <memory> #include <mutex> class b200_local_spi_core : uhd::noncopyable, public uhd::spi_iface { public: - typedef boost::shared_ptr<b200_local_spi_core> sptr; + typedef std::shared_ptr<b200_local_spi_core> sptr; enum perif_t { CODEC, PLL @@ -47,7 +47,7 @@ private: class b200_ref_pll_ctrl : public uhd::usrp::adf4001_ctrl { public: - typedef boost::shared_ptr<b200_ref_pll_ctrl> sptr; + typedef std::shared_ptr<b200_ref_pll_ctrl> sptr; b200_ref_pll_ctrl(b200_local_spi_core::sptr spi); virtual void set_lock_to_ext_ref(bool external); diff --git a/host/lib/usrp/b200/b200_iface.hpp b/host/lib/usrp/b200/b200_iface.hpp index 4389d4eed..a3059bacf 100644 --- a/host/lib/usrp/b200/b200_iface.hpp +++ b/host/lib/usrp/b200/b200_iface.hpp @@ -13,7 +13,7 @@ #include <uhd/types/dict.hpp> #include <uhdlib/usrp/common/ad9361_ctrl.hpp> #include <boost/assign/list_of.hpp> -#include <boost/shared_ptr.hpp> +#include <memory> #include <uhd/utils/noncopyable.hpp> #include <stdint.h> @@ -79,7 +79,7 @@ static const uhd::dict<b200_product_t, std::string> B2XX_FPGA_FILE_NAME = boost: class UHD_API b200_iface: uhd::noncopyable, public virtual uhd::i2c_iface { public: - typedef boost::shared_ptr<b200_iface> sptr; + typedef std::shared_ptr<b200_iface> sptr; /*! * Make a b200 interface object from a control transport diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 1be8c263b..be21ade63 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -20,8 +20,7 @@ #include <boost/filesystem.hpp> #include <boost/lexical_cast.hpp> #include <boost/functional/hash.hpp> -#include <boost/make_shared.hpp> -#include <boost/weak_ptr.hpp> +#include <memory> #include <cstdio> #include <ctime> #include <cmath> @@ -255,7 +254,7 @@ static device::sptr b200_make(const device_addr_t &device_addr) catch (const uhd::usb_error &) { UHD_LOGGER_INFO("B200") << "Detected bad USB state; resetting." ; libusb::device_handle::sptr dev_handle(libusb::device_handle::get_cached_handle( - boost::static_pointer_cast<libusb::special_handle>(handle)->get_device() + std::static_pointer_cast<libusb::special_handle>(handle)->get_device() )); dev_handle->clear_endpoints(B200_USB_CTRL_RECV_ENDPOINT, B200_USB_CTRL_SEND_ENDPOINT); dev_handle->clear_endpoints(B200_USB_DATA_RECV_ENDPOINT, B200_USB_DATA_SEND_ENDPOINT); @@ -578,7 +577,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// _spi_iface = b200_local_spi_core::make(_local_ctrl); if (not (_product == B200MINI or _product == B205MINI)) { - _adf4001_iface = boost::make_shared<b200_ref_pll_ctrl>(_spi_iface); + _adf4001_iface = std::make_shared<b200_ref_pll_ctrl>(_spi_iface); } //////////////////////////////////////////////////////////////////// @@ -588,9 +587,9 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s reset_codec(); ad9361_params::sptr client_settings; if (_product == B200MINI or _product == B205MINI) { - client_settings = boost::make_shared<b2xxmini_ad9361_client_t>(); + client_settings = std::make_shared<b2xxmini_ad9361_client_t>(); } else { - client_settings = boost::make_shared<b200_ad9361_client_t>(); + client_settings = std::make_shared<b200_ad9361_client_t>(); } _codec_ctrl = ad9361_ctrl::make_spi(client_settings, _spi_iface, AD9361_SLAVENO); diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index 6e777d4d6..bd44aa14f 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -36,8 +36,8 @@ #include <uhdlib/usrp/common/ad936x_manager.hpp> #include <uhdlib/usrp/common/adf4001_ctrl.hpp> #include <boost/assign.hpp> -#include <boost/weak_ptr.hpp> #include <mutex> +#include <memory> static const uint8_t B200_FW_COMPAT_NUM_MAJOR = 8; static const uint8_t B200_FW_COMPAT_NUM_MINOR = 0; @@ -138,7 +138,7 @@ private: uhd::usrp::ad9361_ctrl::sptr _codec_ctrl; uhd::usrp::ad936x_manager::sptr _codec_mgr; b200_local_spi_core::sptr _spi_iface; - boost::shared_ptr<uhd::usrp::adf4001_ctrl> _adf4001_iface; + std::shared_ptr<uhd::usrp::adf4001_ctrl> _adf4001_iface; uhd::gps_ctrl::sptr _gps; //transports @@ -146,8 +146,8 @@ private: uhd::transport::zero_copy_if::sptr _ctrl_transport; uhd::usrp::recv_packet_demuxer_3000::sptr _demux; - boost::weak_ptr<uhd::rx_streamer> _rx_streamer; - boost::weak_ptr<uhd::tx_streamer> _tx_streamer; + std::weak_ptr<uhd::rx_streamer> _rx_streamer; + std::weak_ptr<uhd::tx_streamer> _tx_streamer; std::mutex _transport_setup_mutex; @@ -156,13 +156,13 @@ private: typedef uhd::transport::bounded_buffer<uhd::async_metadata_t> async_md_type; struct AsyncTaskData { - boost::shared_ptr<async_md_type> async_md; - boost::weak_ptr<radio_ctrl_core_3000> local_ctrl; - boost::weak_ptr<radio_ctrl_core_3000> radio_ctrl[2]; + std::shared_ptr<async_md_type> async_md; + std::weak_ptr<radio_ctrl_core_3000> local_ctrl; + std::weak_ptr<radio_ctrl_core_3000> radio_ctrl[2]; b200_uart::sptr gpsdo_uart; }; - boost::shared_ptr<AsyncTaskData> _async_task_data; - boost::optional<uhd::msg_task::msg_type_t> handle_async_task(uhd::transport::zero_copy_if::sptr, boost::shared_ptr<AsyncTaskData>); + std::shared_ptr<AsyncTaskData> _async_task_data; + boost::optional<uhd::msg_task::msg_type_t> handle_async_task(uhd::transport::zero_copy_if::sptr, std::shared_ptr<AsyncTaskData>); void register_loopback_self_test(uhd::wb_iface::sptr iface); void set_mb_eeprom(const uhd::usrp::mboard_eeprom_t &); @@ -191,8 +191,8 @@ private: rx_dsp_core_3000::sptr ddc; tx_vita_core_3000::sptr deframer; tx_dsp_core_3000::sptr duc; - boost::weak_ptr<uhd::rx_streamer> rx_streamer; - boost::weak_ptr<uhd::tx_streamer> tx_streamer; + std::weak_ptr<uhd::rx_streamer> rx_streamer; + std::weak_ptr<uhd::tx_streamer> tx_streamer; user_settings_core_3000::sptr user_settings; bool ant_rx2; }; diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index 5a0de430f..88cde6071 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -13,7 +13,7 @@ #include <uhdlib/usrp/common/async_packet_handler.hpp> #include <uhdlib/usrp/common/validate_subdev_spec.hpp> #include <boost/bind.hpp> -#include <boost/make_shared.hpp> +#include <memory> #include <set> using namespace uhd; @@ -37,15 +37,15 @@ size_t b200_impl::max_chan_count(const std::string& direction /* = "" */) for (radio_perifs_t& perif : _radio_perifs) { if ((direction == "RX" or direction.empty()) and not perif.rx_streamer.expired()) { - boost::shared_ptr<sph::recv_packet_streamer> rx_streamer = - boost::dynamic_pointer_cast<sph::recv_packet_streamer>( + std::shared_ptr<sph::recv_packet_streamer> rx_streamer = + std::dynamic_pointer_cast<sph::recv_packet_streamer>( perif.rx_streamer.lock()); max_count = std::max(max_count, rx_streamer->get_num_channels()); } if ((direction == "TX" or direction.empty()) and not perif.tx_streamer.expired()) { - boost::shared_ptr<sph::send_packet_streamer> tx_streamer = - boost::dynamic_pointer_cast<sph::send_packet_streamer>( + std::shared_ptr<sph::send_packet_streamer> tx_streamer = + std::dynamic_pointer_cast<sph::send_packet_streamer>( perif.tx_streamer.lock()); max_count = std::max(max_count, tx_streamer->get_num_channels()); } @@ -142,16 +142,16 @@ void b200_impl::update_tick_rate(const double new_tick_rate) check_tick_rate_with_current_streamers(new_tick_rate); for (radio_perifs_t& perif : _radio_perifs) { - boost::shared_ptr<sph::recv_packet_streamer> my_streamer = - boost::dynamic_pointer_cast<sph::recv_packet_streamer>( + std::shared_ptr<sph::recv_packet_streamer> my_streamer = + std::dynamic_pointer_cast<sph::recv_packet_streamer>( perif.rx_streamer.lock()); if (my_streamer) my_streamer->set_tick_rate(new_tick_rate); perif.framer->set_tick_rate(new_tick_rate); } for (radio_perifs_t& perif : _radio_perifs) { - boost::shared_ptr<sph::send_packet_streamer> my_streamer = - boost::dynamic_pointer_cast<sph::send_packet_streamer>( + std::shared_ptr<sph::send_packet_streamer> my_streamer = + std::dynamic_pointer_cast<sph::send_packet_streamer>( perif.tx_streamer.lock()); if (my_streamer) my_streamer->set_tick_rate(new_tick_rate); @@ -204,8 +204,8 @@ double b200_impl::coerce_rx_samp_rate( void b200_impl::update_rx_samp_rate(const size_t dspno, const double rate) { - boost::shared_ptr<sph::recv_packet_streamer> my_streamer = - boost::dynamic_pointer_cast<sph::recv_packet_streamer>( + std::shared_ptr<sph::recv_packet_streamer> my_streamer = + std::dynamic_pointer_cast<sph::recv_packet_streamer>( _radio_perifs[dspno].rx_streamer.lock()); if (not my_streamer) return; @@ -231,8 +231,8 @@ double b200_impl::coerce_tx_samp_rate( void b200_impl::update_tx_samp_rate(const size_t dspno, const double rate) { - boost::shared_ptr<sph::send_packet_streamer> my_streamer = - boost::dynamic_pointer_cast<sph::send_packet_streamer>( + std::shared_ptr<sph::send_packet_streamer> my_streamer = + std::dynamic_pointer_cast<sph::send_packet_streamer>( _radio_perifs[dspno].tx_streamer.lock()); if (not my_streamer) return; @@ -314,7 +314,7 @@ bool b200_impl::recv_async_msg(async_metadata_t& async_metadata, double timeout) * there. */ boost::optional<uhd::msg_task::msg_type_t> b200_impl::handle_async_task( - uhd::transport::zero_copy_if::sptr xport, boost::shared_ptr<AsyncTaskData> data) + uhd::transport::zero_copy_if::sptr xport, std::shared_ptr<AsyncTaskData> data) { managed_recv_buffer::sptr buff = xport->get_recv_buff(); if (not buff or buff->size() < 8) @@ -405,7 +405,7 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t& args_) } check_streamer_args(args, this->get_tick_rate(), "RX"); - boost::shared_ptr<sph::recv_packet_streamer> my_streamer; + std::shared_ptr<sph::recv_packet_streamer> my_streamer; for (size_t stream_i = 0; stream_i < args.channels.size(); stream_i++) { const size_t radio_index = _tree->access<std::vector<size_t>>("/mboards/0/rx_chan_dsp_mapping") @@ -437,7 +437,7 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t& args_) // make the new streamer given the samples per packet if (not my_streamer) - my_streamer = boost::make_shared<sph::recv_packet_streamer>(spp); + my_streamer = std::make_shared<sph::recv_packet_streamer>(spp); my_streamer->resize(args.channels.size()); // init some streamer stuff @@ -480,8 +480,8 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t& args_) void b200_impl::handle_overflow(const size_t radio_index) { - boost::shared_ptr<sph::recv_packet_streamer> my_streamer = - boost::dynamic_pointer_cast<sph::recv_packet_streamer>( + std::shared_ptr<sph::recv_packet_streamer> my_streamer = + std::dynamic_pointer_cast<sph::recv_packet_streamer>( _radio_perifs[radio_index].rx_streamer.lock()); if (my_streamer->get_num_channels() == 2) // MIMO time { @@ -527,7 +527,7 @@ tx_streamer::sptr b200_impl::get_tx_stream(const uhd::stream_args_t& args_) } check_streamer_args(args, this->get_tick_rate(), "TX"); - boost::shared_ptr<sph::send_packet_streamer> my_streamer; + std::shared_ptr<sph::send_packet_streamer> my_streamer; for (size_t stream_i = 0; stream_i < args.channels.size(); stream_i++) { const size_t radio_index = _tree->access<std::vector<size_t>>("/mboards/0/tx_chan_dsp_mapping") @@ -556,7 +556,7 @@ tx_streamer::sptr b200_impl::get_tx_stream(const uhd::stream_args_t& args_) // make the new streamer given the samples per packet if (not my_streamer) - my_streamer = boost::make_shared<sph::send_packet_streamer>(spp); + my_streamer = std::make_shared<sph::send_packet_streamer>(spp); my_streamer->resize(args.channels.size()); // init some streamer stuff diff --git a/host/lib/usrp/b200/b200_uart.hpp b/host/lib/usrp/b200/b200_uart.hpp index 25dc1171e..c6de5f844 100644 --- a/host/lib/usrp/b200/b200_uart.hpp +++ b/host/lib/usrp/b200/b200_uart.hpp @@ -12,12 +12,12 @@ #include <uhd/transport/zero_copy.hpp> #include <uhd/types/serial.hpp> //uart iface #include <uhd/utils/noncopyable.hpp> -#include <boost/shared_ptr.hpp> +#include <memory> class b200_uart: uhd::noncopyable, public uhd::uart_iface { public: - typedef boost::shared_ptr<b200_uart> sptr; + typedef std::shared_ptr<b200_uart> sptr; static sptr make(uhd::transport::zero_copy_if::sptr, const uint32_t sid); virtual void handle_uart_packet(uhd::transport::managed_recv_buffer::sptr buff) = 0; }; |