From 5ec42578fa9f69e92ae935c16717957a6ea66324 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 5 Aug 2010 16:41:51 -0700 Subject: uhd: created subdevice pair struct for subdev spec (easier than first/second) --- host/lib/usrp/subdev_spec.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'host/lib/usrp/subdev_spec.cpp') diff --git a/host/lib/usrp/subdev_spec.cpp b/host/lib/usrp/subdev_spec.cpp index 69ab6a339..cca5c36b8 100644 --- a/host/lib/usrp/subdev_spec.cpp +++ b/host/lib/usrp/subdev_spec.cpp @@ -25,6 +25,15 @@ using namespace uhd; using namespace uhd::usrp; +subdev_spec_pair_t::subdev_spec_pair_t( + const std::string &db_name, const std::string &sd_name +): + db_name(db_name), + sd_name(sd_name) +{ + /* NOP */ +} + subdev_spec_t::subdev_spec_t(const std::string &markup){ std::vector pairs; boost::split(pairs, markup, boost::is_any_of("\t ")); @@ -33,8 +42,8 @@ subdev_spec_t::subdev_spec_t(const std::string &markup){ std::vector db_sd; boost::split(db_sd, pair, boost::is_any_of(":")); switch(db_sd.size()){ - case 1: this->push_back(pair_t("", db_sd.front())); break; - case 2: this->push_back(pair_t(db_sd.front(), db_sd.back())); break; + case 1: this->push_back(subdev_spec_pair_t("", db_sd.front())); break; + case 2: this->push_back(subdev_spec_pair_t(db_sd.front(), db_sd.back())); break; default: throw std::runtime_error("invalid subdev-spec markup string: "+markup); } } @@ -46,10 +55,10 @@ std::string subdev_spec_t::to_pp_string(void) const{ std::stringstream ss; size_t count = 0; ss << "Subdevice Specification:" << std::endl; - BOOST_FOREACH(const pair_t &pair, *this){ + BOOST_FOREACH(const subdev_spec_pair_t &pair, *this){ ss << boost::format( " Channel %d: Daughterboard %s, Subdevice %s" - ) % (count++) % pair.first % pair.second << std::endl; + ) % (count++) % pair.db_name % pair.sd_name << std::endl; } return ss.str(); } @@ -57,8 +66,8 @@ std::string subdev_spec_t::to_pp_string(void) const{ std::string subdev_spec_t::to_string(void) const{ std::string markup; size_t count = 0; - BOOST_FOREACH(const pair_t &pair, *this){ - markup += ((count++)? " " : "") + pair.first + ":" + pair.second; + BOOST_FOREACH(const subdev_spec_pair_t &pair, *this){ + markup += ((count++)? " " : "") + pair.db_name + ":" + pair.sd_name; } return markup; } -- cgit v1.2.3