From 9fff25f4e5da179ea29ff44278e0415a337870cb Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 12 Feb 2010 18:07:55 -0800 Subject: Added a templated dictionary class because its more useful than map. Made the device addrs into a string:string dict. If its all strings we dont have to change the top level caller for new product. Created shared_iovec class to manage memory for device recvs. Work on the bro/dude control protocol for usrp2. --- lib/device.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'lib/device.cpp') diff --git a/lib/device.cpp b/lib/device.cpp index 4b51a70d4..822733217 100644 --- a/lib/device.cpp +++ b/lib/device.cpp @@ -23,35 +23,37 @@ using namespace uhd; -std::vector device::discover(const device_addr_t & hint = device_addr_t()){ - std::vector device_addrs; - if (hint.type == DEVICE_ADDR_TYPE_UDP){ +device_addrs_t device::discover(const device_addr_t &hint){ + device_addrs_t device_addrs; + if (not hint.has_key("type")){ + //TODO nothing + } + else if (hint["type"] == "test"){ + //make a copy of the hint for testing + device_addr_t test_device_addr = hint; + device_addrs.push_back(test_device_addr); + } + else if (hint["type"] == "udp"){ std::vector usrp2_addrs = usrp::mboard::usrp2::discover(hint); device_addrs.insert(device_addrs.begin(), usrp2_addrs.begin(), usrp2_addrs.end()); } - if (hint.type == DEVICE_ADDR_TYPE_VIRTUAL){ - //make a copy of the hint for virtual testing - device_addr_t virtual_device_addr = hint; - device_addrs.push_back(virtual_device_addr); - } return device_addrs; } -device::sptr device::make(const device_addr_t & hint, size_t which){ +device::sptr device::make(const device_addr_t &hint, size_t which){ std::vector device_addrs = discover(hint); //check that we found any devices if (device_addrs.size() == 0){ throw std::runtime_error(str( - boost::format("No devices found for %s") % hint.to_string() + boost::format("No devices found for %s") % device_addr_to_string(hint) )); } //check that the which index is valid if (device_addrs.size() <= which){ throw std::runtime_error(str( - boost::format("No device at index %d for %s") - % which % hint.to_string() + boost::format("No device at index %d for %s") % which % device_addr_to_string(hint) )); } -- cgit v1.2.3