diff options
author | Josh Blum <josh@joshknows.com> | 2010-01-14 19:02:55 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-01-14 19:02:55 -0800 |
commit | 3b47904f24169904bf65b29091d85ddfc2a7edb4 (patch) | |
tree | c6423c67a341a55ebbeb60c1519635cefb7d6612 /include/usrp_uhd/usrp/dboard | |
parent | b52880892d1a85203e58cdb049877e7ae4c16663 (diff) | |
download | uhd-3b47904f24169904bf65b29091d85ddfc2a7edb4.tar.gz uhd-3b47904f24169904bf65b29091d85ddfc2a7edb4.tar.bz2 uhd-3b47904f24169904bf65b29091d85ddfc2a7edb4.zip |
Switched dboard ctor arguments with a tuple.
Sub-classes only need to pass the single argument,
makes implementation cleaner.
Added a dboard registry and api for the manager.
This way, one could externally register custom dboard from the api.
Diffstat (limited to 'include/usrp_uhd/usrp/dboard')
-rw-r--r-- | include/usrp_uhd/usrp/dboard/base.hpp | 11 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/dboard/manager.hpp | 39 |
2 files changed, 45 insertions, 5 deletions
diff --git a/include/usrp_uhd/usrp/dboard/base.hpp b/include/usrp_uhd/usrp/dboard/base.hpp index 86ab7dde6..09cc9b324 100644 --- a/include/usrp_uhd/usrp/dboard/base.hpp +++ b/include/usrp_uhd/usrp/dboard/base.hpp @@ -8,6 +8,7 @@ #include <usrp_uhd/wax.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> +#include <boost/tuple/tuple.hpp> #include <usrp_uhd/usrp/dboard/interface.hpp> namespace usrp_uhd{ namespace usrp{ namespace dboard{ @@ -19,9 +20,13 @@ namespace usrp_uhd{ namespace usrp{ namespace dboard{ class xcvr_base : boost::noncopyable{ public: typedef boost::shared_ptr<xcvr_base> sptr; + //the constructor args consist of a subdev index and an interface + //derived classes should pass the args into the base class ctor + //but should not have to deal with the internals of the args + typedef boost::tuple<size_t, interface::sptr> ctor_args_t; //structors - xcvr_base(size_t subdev_index, interface::sptr dboard_interface); + xcvr_base(ctor_args_t const&); ~xcvr_base(void); //interface @@ -48,7 +53,7 @@ public: /*! * Create a new rx dboard object, override in subclasses. */ - rx_base(size_t subdev_index, interface::sptr sptr_interface); + rx_base(ctor_args_t const&); virtual ~rx_base(void); @@ -66,7 +71,7 @@ public: /*! * Create a new rx dboard object, override in subclasses. */ - tx_base(size_t subdev_index, interface::sptr sptr_interface); + tx_base(ctor_args_t const&); virtual ~tx_base(void); diff --git a/include/usrp_uhd/usrp/dboard/manager.hpp b/include/usrp_uhd/usrp/dboard/manager.hpp index 29aca83f0..788b8a6eb 100644 --- a/include/usrp_uhd/usrp/dboard/manager.hpp +++ b/include/usrp_uhd/usrp/dboard/manager.hpp @@ -8,6 +8,7 @@ #include <vector> #include <usrp_uhd/wax.hpp> #include <boost/utility.hpp> +#include <boost/function.hpp> #include <boost/shared_ptr.hpp> #include <usrp_uhd/usrp/dboard/base.hpp> @@ -19,12 +20,46 @@ namespace usrp_uhd{ namespace usrp{ namespace dboard{ * Provide wax::obj access to the subdevs inside. */ class manager : boost::noncopyable{ + +public: + //a dboard can be identified by a 16 bit integer + typedef uint16_t dboard_id_t; + + //dboard constructor (each dboard should have a ::make with this signature) + typedef boost::function<xcvr_base::sptr(xcvr_base::ctor_args_t)> dboard_ctor_t; + + /*! + * Register rx subdevices for a given dboard id. + * + * \param dboard_id the rx dboard id + * \param dboard_ctor the dboard constructor function pointer + * \param num_subdevs the number of rx subdevs in this dboard + */ + static void register_rx_subdev( + dboard_id_t dboard_id, + dboard_ctor_t dboard_ctor, + size_t num_subdevs + ); + + /*! + * Register tx subdevices for a given dboard id. + * + * \param dboard_id the tx dboard id + * \param dboard_ctor the dboard constructor function pointer + * \param num_subdevs the number of tx subdevs in this dboard + */ + static void register_tx_subdev( + dboard_id_t dboard_id, + dboard_ctor_t dboard_ctor, + size_t num_subdevs + ); + public: typedef boost::shared_ptr<manager> sptr; //structors manager( - uint16_t rx_dboard_id, - uint16_t tx_dboard_id, + dboard_id_t rx_dboard_id, + dboard_id_t tx_dboard_id, interface::sptr dboard_interface ); ~manager(void); |