From 72b45bb8def087f2eff09ed671de788978853e2a Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 17 Oct 2019 16:01:22 -0700 Subject: uhd: Remove all usages of boost::tuple and friends This replaces all of the following with standard C++ features: - boost::tuple - boost::make_tuple - boost::tuple::get - #include All usages were replaced with search-and-replace scripts (the usages of get could be automatically replaced with a vim macro, the rest was straightforward search-and-replace). --- host/lib/usrp/b100/codec_ctrl.cpp | 6 +++--- host/lib/usrp/cores/rx_dsp_core_200.cpp | 5 +++-- host/lib/usrp/cores/rx_vita_core_3000.cpp | 6 +++--- host/lib/usrp/dboard/db_unknown.cpp | 6 +++--- host/lib/usrp/dboard_manager.cpp | 18 ++++++++---------- host/lib/usrp/gps_ctrl.cpp | 16 ++++++++-------- host/lib/usrp/usrp1/codec_ctrl.cpp | 6 +++--- 7 files changed, 31 insertions(+), 32 deletions(-) (limited to 'host/lib/usrp') diff --git a/host/lib/usrp/b100/codec_ctrl.cpp b/host/lib/usrp/b100/codec_ctrl.cpp index 1dac58916..10cfa686a 100644 --- a/host/lib/usrp/b100/codec_ctrl.cpp +++ b/host/lib/usrp/b100/codec_ctrl.cpp @@ -13,10 +13,10 @@ #include #include #include -#include #include #include "b100_regs.hpp" //spi slave constants #include +#include using namespace uhd; @@ -229,7 +229,7 @@ void b100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){ uint8_t dac_word = uhd::clip(boost::math::iround(volts*0xff/3.3), 0, 0xff); //setup a lookup table for the aux dac params (reg ref, reg addr) - typedef boost::tuple dac_params_t; + typedef std::tuple dac_params_t; uhd::dict aux_dac_to_params = boost::assign::map_list_of (AUX_DAC_A, dac_params_t(&_ad9862_regs.aux_dac_a, 36)) (AUX_DAC_B, dac_params_t(&_ad9862_regs.aux_dac_b, 37)) @@ -239,7 +239,7 @@ void b100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){ //set the aux dac register UHD_ASSERT_THROW(aux_dac_to_params.has_key(which)); uint8_t *reg_ref, reg_addr; - boost::tie(reg_ref, reg_addr) = aux_dac_to_params[which]; + std::tie(reg_ref, reg_addr) = aux_dac_to_params[which]; *reg_ref = dac_word; this->send_reg(reg_addr); } diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index a87b92a50..700a3c207 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #define REG_DSP_RX_FREQ _dsp_base + 0 #define REG_DSP_RX_SCALE_IQ _dsp_base + 4 @@ -105,7 +106,7 @@ public: _continuous_streaming = stream_cmd.stream_mode == stream_cmd_t::STREAM_MODE_START_CONTINUOUS; //setup the mode to instruction flags - typedef boost::tuple inst_t; + typedef std::tuple inst_t; static const uhd::dict mode_to_inst = boost::assign::map_list_of //reload, chain, samps, stop (stream_cmd_t::STREAM_MODE_START_CONTINUOUS, inst_t(true, true, false, false)) @@ -116,7 +117,7 @@ public: //setup the instruction flag values bool inst_reload, inst_chain, inst_samps, inst_stop; - boost::tie(inst_reload, inst_chain, inst_samps, inst_stop) = mode_to_inst[stream_cmd.stream_mode]; + std::tie(inst_reload, inst_chain, inst_samps, inst_stop) = mode_to_inst[stream_cmd.stream_mode]; //calculate the word from flags and length uint32_t cmd_word = 0; diff --git a/host/lib/usrp/cores/rx_vita_core_3000.cpp b/host/lib/usrp/cores/rx_vita_core_3000.cpp index 764fc1334..166e0d83f 100644 --- a/host/lib/usrp/cores/rx_vita_core_3000.cpp +++ b/host/lib/usrp/cores/rx_vita_core_3000.cpp @@ -9,10 +9,10 @@ #include #include #include -#include #include #include #include +#include #define REG_FRAMER_MAXLEN _base + 4*4 + 0 #define REG_FRAMER_SID _base + 4*4 + 4 @@ -94,7 +94,7 @@ struct rx_vita_core_3000_impl : rx_vita_core_3000 _continuous_streaming = stream_cmd.stream_mode == stream_cmd_t::STREAM_MODE_START_CONTINUOUS; //setup the mode to instruction flags - typedef boost::tuple inst_t; + typedef std::tuple inst_t; static const uhd::dict mode_to_inst = boost::assign::map_list_of //reload, chain, samps, stop (stream_cmd_t::STREAM_MODE_START_CONTINUOUS, inst_t(true, true, false, false)) @@ -105,7 +105,7 @@ struct rx_vita_core_3000_impl : rx_vita_core_3000 //setup the instruction flag values bool inst_reload, inst_chain, inst_samps, inst_stop; - boost::tie(inst_reload, inst_chain, inst_samps, inst_stop) = mode_to_inst[stream_cmd.stream_mode]; + std::tie(inst_reload, inst_chain, inst_samps, inst_stop) = mode_to_inst[stream_cmd.stream_mode]; //calculate the word from flags and length uint32_t cmd_word = 0; diff --git a/host/lib/usrp/dboard/db_unknown.cpp b/host/lib/usrp/dboard/db_unknown.cpp index cfa4e31fe..2640ad607 100644 --- a/host/lib/usrp/dboard/db_unknown.cpp +++ b/host/lib/usrp/dboard/db_unknown.cpp @@ -13,8 +13,8 @@ #include #include #include -#include #include +#include using namespace uhd; using namespace uhd::usrp; @@ -24,7 +24,7 @@ using namespace boost::assign; * Utility functions **********************************************************************/ static void warn_if_old_rfx(const dboard_id_t &dboard_id, const std::string &xx){ - typedef boost::tuple old_ids_t; //name, rx_id, tx_id + typedef std::tuple old_ids_t; //name, rx_id, tx_id static const std::vector old_rfx_ids = list_of (old_ids_t("Flex 400 Classic", 0x0004, 0x0008)) (old_ids_t("Flex 900 Classic", 0x0005, 0x0009)) @@ -34,7 +34,7 @@ static void warn_if_old_rfx(const dboard_id_t &dboard_id, const std::string &xx) ; for(const old_ids_t &old_id: old_rfx_ids){ std::string name; dboard_id_t rx_id, tx_id; - boost::tie(name, rx_id, tx_id) = old_id; + std::tie(name, rx_id, tx_id) = old_id; if ( (xx == "RX" and rx_id == dboard_id) or (xx == "TX" and tx_id == dboard_id) diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index ca3612ad5..a4acf2aaf 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -12,10 +12,9 @@ #include #include #include -#include #include #include -#include +#include using namespace uhd; using namespace uhd::usrp; @@ -72,7 +71,7 @@ bool operator==(const dboard_key_t &lhs, const dboard_key_t &rhs){ * storage and registering for dboards **********************************************************************/ //dboard registry tuple: dboard constructor, canonical name, subdev names, container constructor -typedef boost::tuple, dboard_manager::dboard_ctor_t> args_t; +typedef std::tuple, dboard_manager::dboard_ctor_t> args_t; //map a dboard id to a dboard constructor typedef uhd::dict id_to_args_map_t; @@ -90,12 +89,11 @@ static void register_dboard_key( if (dboard_key.is_xcvr()) throw uhd::key_error(str(boost::format( "The dboard id pair [%s, %s] is already registered to %s." - ) % dboard_key.rx_id().to_string() % dboard_key.tx_id().to_string() % get_id_to_args_map()[dboard_key].get<1>())); + ) % dboard_key.rx_id().to_string() % dboard_key.tx_id().to_string() % std::get<1>(get_id_to_args_map()[dboard_key]))); else throw uhd::key_error(str(boost::format( "The dboard id %s is already registered to %s." - ) % dboard_key.xx_id().to_string() % get_id_to_args_map()[dboard_key].get<1>())); - + ) % dboard_key.xx_id().to_string() % std::get<1>(get_id_to_args_map()[dboard_key]))); } get_id_to_args_map()[dboard_key] = args_t(db_subdev_ctor, name, subdev_names, db_container_ctor); } @@ -150,7 +148,7 @@ std::string dboard_id_t::to_cname(void) const{ (key.is_xcvr() and (*this == key.rx_id() or *this == key.tx_id())) ){ if (not cname.empty()) cname += ", "; - cname += get_id_to_args_map()[key].get<1>(); + cname += std::get<1>(get_id_to_args_map()[key]); } } return (cname.empty())? "Unknown" : cname; @@ -319,7 +317,7 @@ void dboard_manager_impl::init( //extract data for the xcvr dboard key dboard_ctor_t subdev_ctor; std::string name; std::vector subdevs; dboard_ctor_t container_ctor; - boost::tie(subdev_ctor, name, subdevs, container_ctor) = get_id_to_args_map()[xcvr_dboard_key]; + std::tie(subdev_ctor, name, subdevs, container_ctor) = get_id_to_args_map()[xcvr_dboard_key]; //create the container class. //a container class exists per N subdevs registered in a register_dboard* call @@ -371,7 +369,7 @@ void dboard_manager_impl::init( //extract data for the rx dboard key dboard_ctor_t rx_dboard_ctor; std::string rx_name; std::vector rx_subdevs; dboard_ctor_t rx_cont_ctor; - boost::tie(rx_dboard_ctor, rx_name, rx_subdevs, rx_cont_ctor) = get_id_to_args_map()[rx_dboard_key]; + std::tie(rx_dboard_ctor, rx_name, rx_subdevs, rx_cont_ctor) = get_id_to_args_map()[rx_dboard_key]; //create the container class. //a container class exists per N subdevs registered in a register_dboard* call @@ -410,7 +408,7 @@ void dboard_manager_impl::init( //extract data for the tx dboard key dboard_ctor_t tx_dboard_ctor; std::string tx_name; std::vector tx_subdevs; dboard_ctor_t tx_cont_ctor; - boost::tie(tx_dboard_ctor, tx_name, tx_subdevs, tx_cont_ctor) = get_id_to_args_map()[tx_dboard_key]; + std::tie(tx_dboard_ctor, tx_name, tx_subdevs, tx_cont_ctor) = get_id_to_args_map()[tx_dboard_key]; //create the container class. //a container class exists per N subdevs registered in a register_dboard* call diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index f9e03b16a..07d7f4ec4 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -17,9 +17,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -47,7 +47,7 @@ gps_ctrl::~gps_ctrl(void){ class gps_ctrl_impl : public gps_ctrl{ private: - std::map > sentences; + std::map> sentences; boost::mutex cache_mutex; boost::system_time _last_cache_update; @@ -64,7 +64,7 @@ private: update_cache(); //mark sentence as touched if (sentences.find(which) != sentences.end()) - sentences[which].get<2>() = true; + std::get<2>(sentences[which]) = true; } while (1) { @@ -82,12 +82,12 @@ private: { age = milliseconds(max_age_ms); } else { - age = boost::get_system_time() - sentences[which].get<1>(); + age = boost::get_system_time() - std::get<1>(sentences[which]); } - if (age < milliseconds(max_age_ms) and (not (wait_for_next and sentences[which].get<2>()))) + if (age < milliseconds(max_age_ms) and (not (wait_for_next and std::get<2>(sentences[which])))) { - sentence = sentences[which].get<0>(); - sentences[which].get<2>() = true; + sentence = std::get<0>(sentences[which]); + std::get<2>(sentences[which]) = true; } } catch(std::exception &e) { UHD_LOGGER_DEBUG("GPS") << "get_sentence: " << e.what(); @@ -183,7 +183,7 @@ private: { if (not msgs[key].empty()) { - sentences[key] = boost::make_tuple(msgs[key], time, false); + sentences[key] = std::make_tuple(msgs[key], time, false); } } diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp index bcb3a28d9..a06ded707 100644 --- a/host/lib/usrp/usrp1/codec_ctrl.cpp +++ b/host/lib/usrp/usrp1/codec_ctrl.cpp @@ -15,11 +15,11 @@ #include #include #include -#include #include #include #include #include +#include using namespace uhd; @@ -245,7 +245,7 @@ void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts) uint8_t dac_word = uhd::clip(boost::math::iround(volts*0xff/3.3), 0, 0xff); //setup a lookup table for the aux dac params (reg ref, reg addr) - typedef boost::tuple dac_params_t; + typedef std::tuple dac_params_t; uhd::dict aux_dac_to_params = boost::assign::map_list_of (AUX_DAC_A, dac_params_t(&_ad9862_regs.aux_dac_a, 36)) (AUX_DAC_B, dac_params_t(&_ad9862_regs.aux_dac_b, 37)) @@ -255,7 +255,7 @@ void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts) //set the aux dac register UHD_ASSERT_THROW(aux_dac_to_params.has_key(which)); uint8_t *reg_ref, reg_addr; - boost::tie(reg_ref, reg_addr) = aux_dac_to_params[which]; + std::tie(reg_ref, reg_addr) = aux_dac_to_params[which]; *reg_ref = dac_word; this->send_reg(reg_addr); } -- cgit v1.2.3