aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/subdev_spec.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-05 16:41:51 -0700
committerJosh Blum <josh@joshknows.com>2010-08-06 12:15:05 -0700
commit5ec42578fa9f69e92ae935c16717957a6ea66324 (patch)
treedb54b506b9dccb857723b7b07ce236986e070e8b /host/lib/usrp/subdev_spec.cpp
parenta333a01ac0d1d0cb011d52f04bed2534a708f944 (diff)
downloaduhd-5ec42578fa9f69e92ae935c16717957a6ea66324.tar.gz
uhd-5ec42578fa9f69e92ae935c16717957a6ea66324.tar.bz2
uhd-5ec42578fa9f69e92ae935c16717957a6ea66324.zip
uhd: created subdevice pair struct for subdev spec (easier than first/second)
Diffstat (limited to 'host/lib/usrp/subdev_spec.cpp')
-rw-r--r--host/lib/usrp/subdev_spec.cpp21
1 files changed, 15 insertions, 6 deletions
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<std::string> 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<std::string> 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;
}