aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-05-02 12:16:41 -0700
committerJosh Blum <josh@joshknows.com>2010-05-02 12:16:41 -0700
commit4a19b43176fe3402d5aefd588d2bf6446877de18 (patch)
tree1fe26f3ca7f51e58b8f4724e06533a356f03628e /host
parent99d55ca11eb67cbbec72660d10a94ea0e9c50f39 (diff)
downloaduhd-4a19b43176fe3402d5aefd588d2bf6446877de18.tar.gz
uhd-4a19b43176fe3402d5aefd588d2bf6446877de18.tar.bz2
uhd-4a19b43176fe3402d5aefd588d2bf6446877de18.zip
Cleaned up some dboard manager construction logic.
Moved the dboard base private stuff into a forward declaration.
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/usrp/dboard_base.hpp13
-rw-r--r--host/lib/usrp/dboard_base.cpp19
-rw-r--r--host/lib/usrp/dboard_manager.cpp36
3 files changed, 39 insertions, 29 deletions
diff --git a/host/include/uhd/usrp/dboard_base.hpp b/host/include/uhd/usrp/dboard_base.hpp
index 2025760ee..c88657b12 100644
--- a/host/include/uhd/usrp/dboard_base.hpp
+++ b/host/include/uhd/usrp/dboard_base.hpp
@@ -35,9 +35,11 @@ namespace uhd{ namespace usrp{
class UHD_API dboard_base : boost::noncopyable{
public:
typedef boost::shared_ptr<dboard_base> sptr;
- //the constructor args consist of a subdev name, interface, and ids
- //derived classes should pass the args into the dboard_base class ctor
- //but should not have to deal with the internals of the args
+ /*!
+ * The constructor args consist of a subdev name, interface, and ids.
+ * Derived classes should pass the args into the dboard_base class ctor
+ * but should not have to deal with the internals of the args.
+ */
typedef boost::tuple<std::string, dboard_iface::sptr, dboard_id_t, dboard_id_t> ctor_args_t;
//structors
@@ -57,9 +59,8 @@ protected:
dboard_id_t get_tx_id(void);
private:
- std::string _subdev_name;
- dboard_iface::sptr _dboard_iface;
- dboard_id_t _rx_id, _tx_id;
+ struct dboard_base_impl;
+ dboard_base_impl *_impl;
};
/*!
diff --git a/host/lib/usrp/dboard_base.cpp b/host/lib/usrp/dboard_base.cpp
index 68e4743d1..bc94ca9ac 100644
--- a/host/lib/usrp/dboard_base.cpp
+++ b/host/lib/usrp/dboard_base.cpp
@@ -24,28 +24,35 @@ using namespace uhd::usrp;
/***********************************************************************
* dboard_base dboard dboard_base class
**********************************************************************/
+struct dboard_base::dboard_base_impl{
+ std::string sd_name;
+ dboard_iface::sptr db_iface;
+ dboard_id_t rx_id, tx_id;
+};
+
dboard_base::dboard_base(ctor_args_t const& args){
- boost::tie(_subdev_name, _dboard_iface, _rx_id, _tx_id) = args;
+ _impl = new dboard_base_impl;
+ boost::tie(_impl->sd_name, _impl->db_iface, _impl->rx_id, _impl->tx_id) = args;
}
dboard_base::~dboard_base(void){
- /* NOP */
+ delete _impl;
}
std::string dboard_base::get_subdev_name(void){
- return _subdev_name;
+ return _impl->sd_name;
}
dboard_iface::sptr dboard_base::get_iface(void){
- return _dboard_iface;
+ return _impl->db_iface;
}
dboard_id_t dboard_base::get_rx_id(void){
- return _rx_id;
+ return _impl->rx_id;
}
dboard_id_t dboard_base::get_tx_id(void){
- return _tx_id;
+ return _impl->tx_id;
}
/***********************************************************************
diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp
index 390c1d3c9..85d651c0c 100644
--- a/host/lib/usrp/dboard_manager.cpp
+++ b/host/lib/usrp/dboard_manager.cpp
@@ -26,6 +26,7 @@
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/assign/list_of.hpp>
+#include <iostream>
using namespace uhd;
using namespace uhd::usrp;
@@ -162,26 +163,27 @@ dboard_manager::sptr dboard_manager::make(
* implementation class methods
**********************************************************************/
static args_t get_dboard_args(
- dboard_id_t dboard_id,
- std::string const& xx_type
+ dboard_iface::unit_t unit,
+ dboard_id_t dboard_id
){
- //special case, its rx and the none id (0xffff)
- if (xx_type == "rx" and dboard_id == dboard_id::NONE){
- return get_dboard_args(0x0001, xx_type);
- }
-
- //special case, its tx and the none id (0xffff)
- if (xx_type == "tx" and dboard_id == dboard_id::NONE){
- return get_dboard_args(0x0000, xx_type);
+ //special case, the none id was provided, use the following ids
+ if (dboard_id == dboard_id::NONE){
+ std::cerr << boost::format(
+ "Warning: unregistered dboard id: %s"
+ " -> defaulting to a basic board"
+ ) % dboard_id::to_string(dboard_id) << std::endl;
+ UHD_ASSERT_THROW(get_id_to_args_map().has_key(0x0001));
+ UHD_ASSERT_THROW(get_id_to_args_map().has_key(0x0000));
+ switch(unit){
+ case dboard_iface::UNIT_RX: return get_dboard_args(unit, 0x0001);
+ case dboard_iface::UNIT_TX: return get_dboard_args(unit, 0x0000);
+ default: UHD_ASSERT_THROW(false);
+ }
}
//verify that there is a registered constructor for this id
if (not get_id_to_args_map().has_key(dboard_id)){
- /*throw std::runtime_error(str(
- boost::format("Unregistered %s dboard id: %s")
- % xx_type % dboard_id::to_string(dboard_id)
- ));*/
- return get_dboard_args(dboard_id::NONE, xx_type);
+ return get_dboard_args(unit, dboard_id::NONE);
}
//return the dboard args for this id
@@ -196,10 +198,10 @@ dboard_manager_impl::dboard_manager_impl(
_iface = iface;
dboard_ctor_t rx_dboard_ctor; std::string rx_name; prop_names_t rx_subdevs;
- boost::tie(rx_dboard_ctor, rx_name, rx_subdevs) = get_dboard_args(rx_dboard_id, "rx");
+ boost::tie(rx_dboard_ctor, rx_name, rx_subdevs) = get_dboard_args(dboard_iface::UNIT_RX, rx_dboard_id);
dboard_ctor_t tx_dboard_ctor; std::string tx_name; prop_names_t tx_subdevs;
- boost::tie(tx_dboard_ctor, tx_name, tx_subdevs) = get_dboard_args(tx_dboard_id, "tx");
+ boost::tie(tx_dboard_ctor, tx_name, tx_subdevs) = get_dboard_args(dboard_iface::UNIT_TX, tx_dboard_id);
//initialize the gpio pins before creating subdevs
set_nice_dboard_if();