diff options
author | Andrej Rode <andrej.rode@ettus.com> | 2017-02-09 23:19:55 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-02-10 16:44:33 -0800 |
commit | 26cc20847cde543e759aa5cee9a27eaa69c5dd9e (patch) | |
tree | eee102333381e2313af59e725d6b7a06b665161f /host/lib/usrp/b200 | |
parent | f3a004faf7d50cbb5564f5e2f67f54ee07e051dd (diff) | |
download | uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.tar.gz uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.tar.bz2 uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.zip |
uhd: replace BOOST_FOREACH with C++11 range-based for loop
Note: This is the first commit that uses for-range, and range-based
for-loops are now usable for UHD development.
Diffstat (limited to 'host/lib/usrp/b200')
-rw-r--r-- | host/lib/usrp/b200/b200_image_loader.cpp | 5 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 26 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_io_impl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_uart.cpp | 3 |
4 files changed, 20 insertions, 22 deletions
diff --git a/host/lib/usrp/b200/b200_image_loader.cpp b/host/lib/usrp/b200/b200_image_loader.cpp index b9c2c0caf..af79a59fc 100644 --- a/host/lib/usrp/b200/b200_image_loader.cpp +++ b/host/lib/usrp/b200/b200_image_loader.cpp @@ -16,7 +16,6 @@ // #include <boost/assign.hpp> -#include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> #include <uhd/exception.hpp> @@ -45,7 +44,7 @@ static b200_iface::sptr get_b200_iface(const image_loader::image_loader_args_t& mboard_eeprom_t eeprom; // Internal use if(dev_handles.size() > 0){ - BOOST_FOREACH(usb_device_handle::sptr dev_handle, dev_handles){ + for(usb_device_handle::sptr dev_handle: dev_handles){ if(dev_handle->firmware_loaded()){ iface = b200_iface::make(usb_control::make(dev_handle,0)); eeprom = mboard_eeprom_t(*iface, "B200"); @@ -74,7 +73,7 @@ static b200_iface::sptr get_b200_iface(const image_loader::image_loader_args_t& std::string err_msg = "Could not resolve given args to a single B2XX device.\n" "Applicable devices:\n"; - BOOST_FOREACH(usb_device_handle::sptr dev_handle, applicable_dev_handles){ + for(usb_device_handle::sptr dev_handle: applicable_dev_handles){ eeprom = mboard_eeprom_t(*b200_iface::make(usb_control::make(dev_handle,0)), "B200"); err_msg += str(boost::format(" * %s (serial=%s)\n") % B2XX_STR_NAMES.get(get_b200_product(dev_handle, mb_eeprom), "B2XX") diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index e2a0e0b70..62f0c2f59 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -172,7 +172,7 @@ static device_addrs_t b200_find(const device_addr_t &hint) //Return an empty list of addresses when an address or resource is specified, //since an address and resource is intended for a different, non-USB, device. - BOOST_FOREACH(device_addr_t hint_i, separate_device_addr(hint)) { + for(device_addr_t hint_i: separate_device_addr(hint)) { if (hint_i.has_key("addr") || hint_i.has_key("resource")) return b200_addrs; } @@ -182,7 +182,7 @@ static device_addrs_t b200_find(const device_addr_t &hint) // so that re-enumeration after fw load can occur successfully. // This requirement is a courtesy of libusb1.0 on windows. size_t found = 0; - BOOST_FOREACH(usb_device_handle::sptr handle, get_b200_device_handles(hint)) { + for(usb_device_handle::sptr handle: get_b200_device_handles(hint)) { //extract the firmware path for the b200 std::string b200_fw_image; try{ @@ -213,7 +213,7 @@ static device_addrs_t b200_find(const device_addr_t &hint) //search for the device until found or timeout while (boost::get_system_time() < timeout_time and b200_addrs.empty() and found != 0) { - BOOST_FOREACH(usb_device_handle::sptr handle, get_b200_device_handles(hint)) + for(usb_device_handle::sptr handle: get_b200_device_handles(hint)) { usb_control::sptr control; try{control = usb_control::make(handle, 0);} @@ -344,7 +344,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s std::vector<usb_device_handle::sptr> device_list = usb_device_handle::get_device_list(vid_pid_pair_list); //locate the matching handle in the device list - BOOST_FOREACH(usb_device_handle::sptr dev_handle, device_list) { + for(usb_device_handle::sptr dev_handle: device_list) { try { if (dev_handle->get_serial() == device_addr["serial"]){ handle = dev_handle; @@ -500,7 +500,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s if (_gps and _gps->gps_detected()) { //UHD_MSG(status) << "found" << std::endl; - BOOST_FOREACH(const std::string &name, _gps->get_sensors()) + for(const std::string &name: _gps->get_sensors()) { _tree->create<sensor_value_t>(mb_path / "sensors" / name) .set_publisher(boost::bind(&gps_ctrl::get_sensor, _gps, name)); @@ -621,7 +621,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s this->setup_radio(i); //now test each radio module's connection to the codec interface - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { _codec_mgr->loopback_self_test( boost::bind( @@ -641,7 +641,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s .add_coerced_subscriber(boost::bind(&b200_impl::sync_times, this)); _tree->create<time_spec_t>(mb_path / "time" / "pps") .set_publisher(boost::bind(&time_core_3000::get_time_last_pps, _radio_perifs[0].time64)); - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { _tree->access<time_spec_t>(mb_path / "time" / "pps") .add_coerced_subscriber(boost::bind(&time_core_3000::set_time_next_pps, perif.time64, _1)); @@ -670,7 +670,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s // front panel gpio //////////////////////////////////////////////////////////////////// _radio_perifs[0].fp_gpio = gpio_atr_3000::make(_radio_perifs[0].ctrl, TOREG(SR_FP_GPIO), RB32_FP_GPIO); - BOOST_FOREACH(const gpio_attr_map_t::value_type attr, gpio_attr_map) + for(const gpio_attr_map_t::value_type attr: gpio_attr_map) { _tree->create<uint32_t>(mb_path / "gpio" / "FP0" / attr.second) .set(0) @@ -701,11 +701,11 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //subdev spec contains full width of selections subdev_spec_t rx_spec, tx_spec; - BOOST_FOREACH(const std::string &fe, _tree->list(mb_path / "dboards" / "A" / "rx_frontends")) + for(const std::string &fe: _tree->list(mb_path / "dboards" / "A" / "rx_frontends")) { rx_spec.push_back(subdev_spec_pair_t("A", fe)); } - BOOST_FOREACH(const std::string &fe, _tree->list(mb_path / "dboards" / "A" / "tx_frontends")) + for(const std::string &fe: _tree->list(mb_path / "dboards" / "A" / "tx_frontends")) { tx_spec.push_back(subdev_spec_pair_t("A", fe)); } @@ -830,7 +830,7 @@ void b200_impl::setup_radio(const size_t dspno) // create RF frontend interfacing //////////////////////////////////////////////////////////////////// static const std::vector<direction_t> dirs = boost::assign::list_of(RX_DIRECTION)(TX_DIRECTION); - BOOST_FOREACH(direction_t dir, dirs) { + for(direction_t dir: dirs) { const std::string x = (dir == RX_DIRECTION) ? "rx" : "tx"; const std::string key = std::string(((dir == RX_DIRECTION) ? "RX" : "TX")) + std::string(((dspno == _fe1) ? "1" : "2")); const fs_path rf_fe_path @@ -932,7 +932,7 @@ double b200_impl::set_tick_rate(const double new_tick_rate) _tick_rate = _codec_ctrl->set_clock_rate(new_tick_rate); UHD_MSG(status) << std::endl << (boost::format("Actually got clock rate %.6f MHz.") % (_tick_rate/1e6)) << std::endl; - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { perif.time64->set_tick_rate(_tick_rate); perif.time64->self_test(); @@ -1088,7 +1088,7 @@ void b200_impl::update_time_source(const std::string &source) void b200_impl::set_time(const uhd::time_spec_t& t) { - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) perif.time64->set_time_sync(t); _local_ctrl->poke32(TOREG(SR_CORE_SYNC), 1 << 2 | uint32_t(_time_source)); _local_ctrl->poke32(TOREG(SR_CORE_SYNC), _time_source); diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index 0a00b9402..09aaff7ed 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -45,7 +45,7 @@ void b200_impl::check_tick_rate_with_current_streamers(double rate) size_t b200_impl::max_chan_count(const std::string &direction /* = "" */) { size_t max_count = 0; - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + 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 = @@ -97,7 +97,7 @@ void b200_impl::set_auto_tick_rate( for (int i = 0; i < 2; i++) { // Loop through rx and tx std::string dir = (i == 0) ? "tx" : "rx"; // We assume all 'set' DSPs are being used. - BOOST_FOREACH(const std::string &dsp_no, _tree->list(str(boost::format("/mboards/0/%s_dsps") % dir))) { + for(const std::string &dsp_no: _tree->list(str(boost::format("/mboards/0/%s_dsps") % dir))) { fs_path dsp_path = str(boost::format("/mboards/0/%s_dsps/%s") % dir % dsp_no); if (dsp_path == tree_dsp_path) { continue; @@ -146,14 +146,14 @@ void b200_impl::update_tick_rate(const double new_tick_rate) { check_tick_rate_with_current_streamers(new_tick_rate); - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { boost::shared_ptr<sph::recv_packet_streamer> my_streamer = boost::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); } - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { boost::shared_ptr<sph::send_packet_streamer> my_streamer = boost::dynamic_pointer_cast<sph::send_packet_streamer>(perif.tx_streamer.lock()); diff --git a/host/lib/usrp/b200/b200_uart.cpp b/host/lib/usrp/b200/b200_uart.cpp index 3c49ebf2a..016dd4ca3 100644 --- a/host/lib/usrp/b200/b200_uart.cpp +++ b/host/lib/usrp/b200/b200_uart.cpp @@ -23,7 +23,6 @@ #include <uhd/utils/msg.hpp> #include <uhd/types/time_spec.hpp> #include <uhd/exception.hpp> -#include <boost/foreach.hpp> using namespace uhd; using namespace uhd::transport; @@ -69,7 +68,7 @@ struct b200_uart_impl : b200_uart void write_uart(const std::string &buff) { - BOOST_FOREACH(const char ch, buff) + for(const char ch: buff) { this->send_char(ch); } |