summaryrefslogtreecommitdiffstats
path: root/lib/device.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-01-16 16:29:31 -0800
committerJosh Blum <josh@joshknows.com>2010-01-16 16:29:31 -0800
commit5b42b774d9ac1e74fb2916bf58085fe19ecb6720 (patch)
treeb19c441ac2f5d2ff6be09142916775b78a646d9b /lib/device.cpp
parent379d486ed21aace7f8b37d61f713bdc6088b39e5 (diff)
downloaduhd-5b42b774d9ac1e74fb2916bf58085fe19ecb6720.tar.gz
uhd-5b42b774d9ac1e74fb2916bf58085fe19ecb6720.tar.bz2
uhd-5b42b774d9ac1e74fb2916bf58085fe19ecb6720.zip
Created device interface for discovery, access, configuration...
Diffstat (limited to 'lib/device.cpp')
-rw-r--r--lib/device.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/device.cpp b/lib/device.cpp
new file mode 100644
index 000000000..fe655ec7a
--- /dev/null
+++ b/lib/device.cpp
@@ -0,0 +1,43 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+
+#include <usrp_uhd/device.hpp>
+#include <boost/format.hpp>
+
+using namespace usrp_uhd;
+
+std::vector<device_addr_t> device::discover(const device_addr_t& hint){
+ std::vector<device_addr_t> device_addrs;
+ if (hint.type == DEVICE_ADDR_TYPE_VIRTUAL){
+ //TODO device_addrs.push_back(...);
+ }
+ return device_addrs;
+}
+
+device::sptr device::make(const device_addr_t& hint, size_t which){
+ std::vector<device_addr_t> 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()
+ ));
+ }
+ //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()
+ ));
+ }
+ //create the new device with the discovered address
+ return sptr(new device(device_addrs.at(which)));
+}
+
+device::device(const device_addr_t&){
+ /* NOP */
+}
+
+device::~device(void){
+ /* NOP */
+}