diff options
-rw-r--r-- | host/include/uhd/usrp/dboard_manager.hpp | 35 | ||||
-rw-r--r-- | host/lib/usrp/dboard_manager.cpp | 58 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/dboard_impl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 4 |
4 files changed, 69 insertions, 32 deletions
diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp index d927f6231..042947ac4 100644 --- a/host/include/uhd/usrp/dboard_manager.hpp +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -18,13 +18,11 @@ #ifndef INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP #define INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP -#include <uhd/dict.hpp> -#include <uhd/wax.hpp> #include <uhd/props.hpp> -#include <boost/utility.hpp> -#include <boost/shared_ptr.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_id.hpp> +#include <boost/utility.hpp> +#include <boost/shared_ptr.hpp> namespace uhd{ namespace usrp{ @@ -36,6 +34,7 @@ namespace uhd{ namespace usrp{ class dboard_manager : boost::noncopyable{ public: + typedef boost::shared_ptr<dboard_manager> sptr; //dboard constructor (each dboard should have a ::make with this signature) typedef dboard_base::sptr(*dboard_ctor_t)(dboard_base::ctor_args_t const&); @@ -53,28 +52,24 @@ public: const prop_names_t &subdev_names ); -public: - typedef boost::shared_ptr<dboard_manager> sptr; - //structors - dboard_manager( + /*! + * Make a new dboard manager. + * \param rx_dboard_id the id of the rx dboard + * \param tx_dboard_id the id of the tx dboard + * \param interface the custom dboard interface + * \return an sptr to the new dboard manager + */ + static sptr make( dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, dboard_interface::sptr interface ); - ~dboard_manager(void); //dboard_interface - prop_names_t get_rx_subdev_names(void); - prop_names_t get_tx_subdev_names(void); - wax::obj get_rx_subdev(const std::string &subdev_name); - wax::obj get_tx_subdev(const std::string &subdev_name); - -private: - //list of rx and tx dboards in this dboard_manager - //each dboard here is actually a subdevice proxy - //the subdevice proxy is internal to the cpp file - uhd::dict<std::string, wax::obj> _rx_dboards; - uhd::dict<std::string, wax::obj> _tx_dboards; + virtual prop_names_t get_rx_subdev_names(void) = 0; + virtual prop_names_t get_tx_subdev_names(void) = 0; + virtual wax::obj get_rx_subdev(const std::string &subdev_name) = 0; + virtual wax::obj get_tx_subdev(const std::string &subdev_name) = 0; }; }} //namespace diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 4d52f82e8..f0846db25 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -17,6 +17,7 @@ #include <uhd/usrp/dboard_manager.hpp> #include <uhd/utils.hpp> +#include <uhd/dict.hpp> #include <boost/assign/list_of.hpp> #include <boost/tuple/tuple.hpp> #include <boost/format.hpp> @@ -66,6 +67,33 @@ void dboard_manager::register_subdevs( } /*********************************************************************** + * dboard manager implementation class + **********************************************************************/ +class dboard_manager_impl : public dboard_manager{ + +public: + dboard_manager_impl( + dboard_id_t rx_dboard_id, + dboard_id_t tx_dboard_id, + dboard_interface::sptr interface + ); + ~dboard_manager_impl(void); + + //dboard_interface + prop_names_t get_rx_subdev_names(void); + prop_names_t get_tx_subdev_names(void); + wax::obj get_rx_subdev(const std::string &subdev_name); + wax::obj get_tx_subdev(const std::string &subdev_name); + +private: + //list of rx and tx dboards in this dboard_manager + //each dboard here is actually a subdevice proxy + //the subdevice proxy is internal to the cpp file + uhd::dict<std::string, wax::obj> _rx_dboards; + uhd::dict<std::string, wax::obj> _tx_dboards; +}; + +/*********************************************************************** * internal helper classes **********************************************************************/ /*! @@ -109,7 +137,20 @@ private: }; /*********************************************************************** - * dboard dboard_manager methods + * make routine for dboard manager + **********************************************************************/ +dboard_manager::sptr dboard_manager::make( + dboard_id_t rx_dboard_id, + dboard_id_t tx_dboard_id, + dboard_interface::sptr interface +){ + return dboard_manager::sptr( + new dboard_manager_impl(rx_dboard_id, tx_dboard_id, interface) + ); +} + +/*********************************************************************** + * implementation class methods **********************************************************************/ static args_t get_dboard_args( dboard_id_t dboard_id, @@ -128,7 +169,8 @@ static args_t get_dboard_args( //verify that there is a registered constructor for this id if (not id_to_args_map.has_key(dboard_id)){ throw std::runtime_error(str( - boost::format("Unknown %s dboard id: 0x%04x") % xx_type % dboard_id + boost::format("Unregistered %s dboard id: %s") + % xx_type % dboard_id::to_string(dboard_id) )); } @@ -136,7 +178,7 @@ static args_t get_dboard_args( return id_to_args_map[dboard_id]; } -dboard_manager::dboard_manager( +dboard_manager_impl::dboard_manager_impl( dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, dboard_interface::sptr interface @@ -202,19 +244,19 @@ dboard_manager::dboard_manager( } } -dboard_manager::~dboard_manager(void){ +dboard_manager_impl::~dboard_manager_impl(void){ /* NOP */ } -prop_names_t dboard_manager::get_rx_subdev_names(void){ +prop_names_t dboard_manager_impl::get_rx_subdev_names(void){ return _rx_dboards.get_keys(); } -prop_names_t dboard_manager::get_tx_subdev_names(void){ +prop_names_t dboard_manager_impl::get_tx_subdev_names(void){ return _tx_dboards.get_keys(); } -wax::obj dboard_manager::get_rx_subdev(const std::string &subdev_name){ +wax::obj dboard_manager_impl::get_rx_subdev(const std::string &subdev_name){ if (not _rx_dboards.has_key(subdev_name)) throw std::invalid_argument( str(boost::format("Unknown rx subdev name %s") % subdev_name) ); @@ -222,7 +264,7 @@ wax::obj dboard_manager::get_rx_subdev(const std::string &subdev_name){ return wax::cast<subdev_proxy::sptr>(_rx_dboards[subdev_name])->get_link(); } -wax::obj dboard_manager::get_tx_subdev(const std::string &subdev_name){ +wax::obj dboard_manager_impl::get_tx_subdev(const std::string &subdev_name){ if (not _tx_dboards.has_key(subdev_name)) throw std::invalid_argument( str(boost::format("Unknown tx subdev name %s") % subdev_name) ); diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index b38a51b04..32c64f541 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -47,8 +47,8 @@ void usrp2_impl::dboard_init(void){ dboard_interface::sptr _dboard_interface( new usrp2_dboard_interface(this) ); - dboard_manager::sptr _dboard_manager( - new dboard_manager(rx_dboard_id, tx_dboard_id, _dboard_interface) + dboard_manager::sptr _dboard_manager = dboard_manager::make( + rx_dboard_id, tx_dboard_id, _dboard_interface ); //load dboards diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index ac0c3c88a..2b4e8fe39 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -90,9 +90,9 @@ device::sptr usrp2::make(const device_addr_t &device_addr){ ); //create the usrp2 implementation guts - return device::sptr(dynamic_cast<device*>( + return device::sptr( new usrp2_impl(ctrl_transport, data_transport) - )); + ); } /*********************************************************************** |