From b20c9fc836a0f32666739dcd143692149eb66c68 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 15 Sep 2011 13:10:02 -0700 Subject: uhd: separate_device_addr, copy globals across entire address --- host/lib/types/device_addr.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp index 45d885adc..e329bd390 100644 --- a/host/lib/types/device_addr.cpp +++ b/host/lib/types/device_addr.cpp @@ -96,7 +96,8 @@ device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){ } } //------------------------------------------------------------------ - device_addrs_t dev_addrs; + device_addrs_t dev_addrs(1); //must be at least one (obviously) + std::vector global_keys; //keys that apply to all (no numerical suffix) BOOST_FOREACH(const std::string &key, dev_addr.keys()){ boost::cmatch matches; if (not boost::regex_match(key.c_str(), matches, boost::regex("^(\\D+)(\\d*)$"))){ @@ -104,10 +105,21 @@ device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){ } std::string key_part(matches[1].first, matches[1].second); std::string num_part(matches[2].first, matches[2].second); - size_t num = (num_part.empty())? 0 : boost::lexical_cast(num_part); + if (num_part.empty()){ //no number? save it for later + global_keys.push_back(key); + continue; + } + const size_t num = boost::lexical_cast(num_part); dev_addrs.resize(std::max(num+1, dev_addrs.size())); dev_addrs[num][key_part] = dev_addr[key]; } + + //copy the global settings across all device addresses + BOOST_FOREACH(device_addr_t &my_dev_addr, dev_addrs){ + BOOST_FOREACH(const std::string &global_key, global_keys){ + my_dev_addr[global_key] = dev_addr[global_key]; + } + } return dev_addrs; } -- cgit v1.2.3