diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/include/uhd/property.hpp | 108 | ||||
-rw-r--r-- | host/include/uhd/property_tree.hpp | 63 | ||||
-rw-r--r-- | host/include/uhd/property_tree.ipp | 96 | ||||
-rw-r--r-- | host/include/uhd/types/sensors.hpp | 3 | ||||
-rw-r--r-- | host/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/lib/types/sensors.cpp | 7 | ||||
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.hpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/dboard_manager.cpp | 57 | ||||
-rw-r--r-- | host/lib/usrp2/io_impl.cpp | 10 | ||||
-rw-r--r-- | host/lib/usrp2/usrp2_impl.cpp | 18 | ||||
-rw-r--r-- | host/tests/property_test.cpp | 42 |
13 files changed, 234 insertions, 190 deletions
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index 1ee3e69df..49562a7a0 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -26,7 +26,7 @@ INSTALL(FILES convert.hpp device.hpp exception.hpp - property.hpp + property_tree.ipp property_tree.hpp version.hpp wax.hpp diff --git a/host/include/uhd/property.hpp b/host/include/uhd/property.hpp deleted file mode 100644 index 10ce463e0..000000000 --- a/host/include/uhd/property.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// -// Copyright 2011 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_UHD_PROPERTY_HPP -#define INCLUDED_UHD_PROPERTY_HPP - -#include <uhd/config.hpp> -#include <boost/foreach.hpp> -#include <boost/function.hpp> -#include <list> - -namespace uhd{ - -/*! - * A templated property interface for holding a value - * and registering callbacks when that value changes. - */ -template <typename T> class UHD_API property{ -public: - typedef boost::function<void(const T &)> subscriber_type; - typedef boost::function<T(void)> publisher_type; - typedef boost::function<T(const T &)> master_type; - - //! Default constructor - property(void){ - /* NOP */ - } - - //! Value initializer constructor - property(const T &value){ - _value = value; - } - - /*! - * Register a master subscriber into the property. - * A master is a special subscriber that coerces the value. - * Only one master may be registered per property. - * Registering a master replaces the previous master. - */ - void subscribe_master(const master_type &master){ - _master = master; - } - - /*! - * Register a publisher into the property. - * A publisher is a special callback the provides the value. - * Publishers are useful for creating read-only properties. - * Only one publisher may be registered per property. - * Registering a publisher replaces the previous publisher. - */ - void publish(const publisher_type &publisher){ - _publisher = publisher; - } - - /*! - * Register a subscriber into the property. - * All subscribers are called when the value changes. - * Once a subscriber is registered, it cannot be unregistered. - */ - void subscribe(const subscriber_type &subscriber){ - _subscribers.push_back(subscriber); - } - - //! Update calls all subscribers w/ the current value - void update(void){ - this->set(this->get()); - } - - /*! - * Set the new value and call all subscribers. - * The master is called first to coerce the value. - */ - void set(const T &value){ - _value = _master.empty()? value : _master(value); - BOOST_FOREACH(subscriber_type &subscriber, _subscribers){ - subscriber(_value); //let errors propagate - } - } - - //! Get the current value of this property - T get(void) const{ - return _publisher.empty()? _value : _publisher(); - } - -private: - std::list<subscriber_type> _subscribers; - publisher_type _publisher; - master_type _master; - T _value; -}; - -} //namespace uhd - -#endif /* INCLUDED_UHD_PROPERTY_HPP */ diff --git a/host/include/uhd/property_tree.hpp b/host/include/uhd/property_tree.hpp index b23a6cc37..630e86bba 100644 --- a/host/include/uhd/property_tree.hpp +++ b/host/include/uhd/property_tree.hpp @@ -19,16 +19,67 @@ #define INCLUDED_UHD_PROPERTY_TREE_HPP #include <uhd/config.hpp> -#include <uhd/property.hpp> #include <boost/any.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> +#include <boost/function.hpp> #include <boost/filesystem/path.hpp> #include <vector> namespace uhd{ /*! + * A templated property interface for holding a value + * and registering callbacks when that value changes. + */ +template <typename T> class UHD_API property : boost::noncopyable{ +public: + typedef boost::shared_ptr<property> sptr; + typedef boost::function<void(const T &)> subscriber_type; + typedef boost::function<T(void)> publisher_type; + typedef boost::function<T(const T &)> master_type; + + //! Make a new property object + static sptr make(void); + + /*! + * Register a master subscriber into the property. + * A master is a special subscriber that coerces the value. + * Only one master may be registered per property. + * Registering a master replaces the previous master. + */ + virtual property<T> &subscribe_master(const master_type &master) = 0; + + /*! + * Register a publisher into the property. + * A publisher is a special callback the provides the value. + * Publishers are useful for creating read-only properties. + * Only one publisher may be registered per property. + * Registering a publisher replaces the previous publisher. + */ + virtual property<T> &publish(const publisher_type &publisher) = 0; + + /*! + * Register a subscriber into the property. + * All subscribers are called when the value changes. + * Once a subscriber is registered, it cannot be unregistered. + */ + virtual property<T> &subscribe(const subscriber_type &subscriber) = 0; + + //! Update calls all subscribers w/ the current value + virtual property<T> &update(void) = 0; + + /*! + * Set the new value and call all subscribers. + * The master is called first to coerce the value. + */ + virtual property<T> &set(const T &value) = 0; + + //! Get the current value of this property + virtual T get(void) const = 0; +}; + +/*! * The property tree provides a file system structure for accessing properties. */ class UHD_API property_tree : boost::noncopyable{ @@ -49,14 +100,10 @@ public: virtual std::vector<std::string> list(const path_type &path) = 0; //! Create a new property entry in the tree - template <typename T> void create(const path_type &path, const property<T> &prop = property<T>()){ - return this->_create(path, prop); - } + template <typename T> property<T> &create(const path_type &path); //! Get access to a property in the tree - template <typename T> property<T> access(const path_type &path){ - return boost::any_cast<property<T> >(this->_access(path)); - } + template <typename T> property<T> &access(const path_type &path); protected: //! Internal create property with wild-card type @@ -69,4 +116,6 @@ protected: } //namespace uhd +#include <uhd/property_tree.ipp> + #endif /* INCLUDED_UHD_PROPERTY_TREE_HPP */ diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp new file mode 100644 index 000000000..6bd88929d --- /dev/null +++ b/host/include/uhd/property_tree.ipp @@ -0,0 +1,96 @@ +// +// Copyright 2011 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_UHD_PROPERTY_TREE_IPP +#define INCLUDED_UHD_PROPERTY_TREE_IPP + +#include <boost/foreach.hpp> +#include <vector> + +/*********************************************************************** + * Implement templated property impl + **********************************************************************/ +namespace uhd{ +namespace /*anon*/{ + +template <typename T> class UHD_API property_impl : public property<T>{ +public: + + property<T> &subscribe_master(const typename property<T>::master_type &master){ + _master = master; + return *this; + } + + property<T> &publish(const typename property<T>::publisher_type &publisher){ + _publisher = publisher; + return *this; + } + + property<T> &subscribe(const typename property<T>::subscriber_type &subscriber){ + _subscribers.push_back(subscriber); + return *this; + } + + property<T> &update(void){ + this->set(this->get()); + return *this; + } + + property<T> &set(const T &value){ + _value = _master.empty()? value : _master(value); + BOOST_FOREACH(typename property<T>::subscriber_type &subscriber, _subscribers){ + subscriber(this->get()); //let errors propagate + } + return *this; + } + + T get(void) const{ + return _publisher.empty()? boost::any_cast<T>(_value) : _publisher(); + } + +private: + std::vector<typename property<T>::subscriber_type> _subscribers; + typename property<T>::publisher_type _publisher; + typename property<T>::master_type _master; + boost::any _value; //any type so we can assign structs w/ const members +}; + +} //namespace /*anon*/ + +template <typename T> typename property<T>::sptr property<T>::make(void){ + return sptr(new property_impl<T>()); +} + +} //namespace uhd + +/*********************************************************************** + * Implement templated methods for the property tree + **********************************************************************/ +namespace uhd{ + + template <typename T> property<T> &property_tree::create(const path_type &path){ + this->_create(path, property<T>::make()); + return this->access<T>(path); + } + + template <typename T> property<T> &property_tree::access(const path_type &path){ + return *boost::any_cast<typename property<T>::sptr>(this->_access(path)); + } + +} //namespace uhd + +#endif /* INCLUDED_UHD_PROPERTY_TREE_IPP */ diff --git a/host/include/uhd/types/sensors.hpp b/host/include/uhd/types/sensors.hpp index a43546262..529e1e3e3 100644 --- a/host/include/uhd/types/sensors.hpp +++ b/host/include/uhd/types/sensors.hpp @@ -37,9 +37,6 @@ namespace uhd{ */ struct UHD_API sensor_value_t{ - //! Default constructor - sensor_value_t(void); - /*! * Create a sensor value from a boolean. * \param name the name of the sensor diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index a8f490f0a..390a75f09 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -72,7 +72,7 @@ INCLUDE_SUBDIRECTORY(types) INCLUDE_SUBDIRECTORY(convert) INCLUDE_SUBDIRECTORY(transport) INCLUDE_SUBDIRECTORY(usrp) -INCLUDE_SUBDIRECTORY(usrp2) +#INCLUDE_SUBDIRECTORY(usrp2) INCLUDE_SUBDIRECTORY(utils) ######################################################################## diff --git a/host/lib/types/sensors.cpp b/host/lib/types/sensors.cpp index 5e1e8691c..52a63d14c 100644 --- a/host/lib/types/sensors.cpp +++ b/host/lib/types/sensors.cpp @@ -22,13 +22,6 @@ using namespace uhd; -sensor_value_t::sensor_value_t(void): - name(""), value(""), - unit(""), type(STRING) -{ - /* NOP */ -} - sensor_value_t::sensor_value_t( const std::string &name, bool value, diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index 5aa32c630..b13cc8f03 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -48,10 +48,18 @@ public: rx_dsp_core_200_impl( wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, - const boost::uint32_t sid + const boost::uint32_t sid, const bool lingering_packet ): _iface(iface), _dsp_base(dsp_base), _ctrl_base(ctrl_base) { + //This is a hack/fix for the lingering packet problem. + //The caller should also flush the recv transports + if (lingering_packet){ + stream_cmd_t stream_cmd(stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); + stream_cmd.num_samps = 1; + issue_stream_command(stream_cmd); + } + _iface->poke32(REG_RX_CTRL_CLEAR, 1); //reset _iface->poke32(REG_RX_CTRL_NCHANNELS, 1); _iface->poke32(REG_RX_CTRL_VRT_HDR, 0 @@ -162,6 +170,6 @@ private: bool _continuous_streaming; }; -rx_dsp_core_200::sptr rx_dsp_core_200::make(wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, const boost::uint32_t sid){ - return sptr(new rx_dsp_core_200_impl(iface, dsp_base, ctrl_base, sid)); +rx_dsp_core_200::sptr rx_dsp_core_200::make(wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, const boost::uint32_t sid, const bool lingering_packet){ + return sptr(new rx_dsp_core_200_impl(iface, dsp_base, ctrl_base, sid, lingering_packet)); } diff --git a/host/lib/usrp/cores/rx_dsp_core_200.hpp b/host/lib/usrp/cores/rx_dsp_core_200.hpp index 6bc7c6102..c496fca76 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.hpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.hpp @@ -32,7 +32,7 @@ public: static sptr make( wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, - const boost::uint32_t sid + const boost::uint32_t sid, const bool lingering_packet = false ); virtual void set_nsamps_per_packet(const size_t nsamps) = 0; diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 5b9186a32..bff55009e 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -471,54 +471,43 @@ void dboard_manager::populate_prop_tree_from_subdev( const property_tree::path_type &root, wax::obj subdev ){ - tree->create(root / "name", property<std::string>(subdev[SUBDEV_PROP_NAME].as<std::string>())); + tree->create<std::string>(root / "name").set(subdev[SUBDEV_PROP_NAME].as<std::string>()); const prop_names_t sensor_names = subdev[SUBDEV_PROP_SENSOR_NAMES].as<prop_names_t>(); BOOST_FOREACH(const std::string &name, sensor_names){ - property<sensor_value_t> sensor_prop; - sensor_prop.publish(boost::bind(&get_sensor, subdev, name)); - tree->create(root / "sensors" / name, sensor_prop); + tree->create<sensor_value_t>(root / "sensors" / name) + .publish(boost::bind(&get_sensor, subdev, name)); } const prop_names_t gain_names = subdev[SUBDEV_PROP_GAIN_NAMES].as<prop_names_t>(); BOOST_FOREACH(const std::string &name, gain_names){ - property<double> gain_prop; - gain_prop.subscribe_master(boost::bind(&get_set_gain, subdev, name, _1)); - tree->create(root / "gains" / name / "value", gain_prop); - property<meta_range_t> gain_range_prop; - gain_range_prop.publish(boost::bind(&get_gain_range, subdev, name)); - tree->create(root / "gains" / name / "range", gain_range_prop); + tree->create<double>(root / "gains" / name / "value") + .subscribe_master(boost::bind(&get_set_gain, subdev, name, _1)); + tree->create<meta_range_t>(root / "gains" / name / "range") + .publish(boost::bind(&get_gain_range, subdev, name)); } - property<double> freq_prop; - freq_prop.subscribe_master(boost::bind(&get_set_freq, subdev, _1)); - tree->create(root / "freq/value", freq_prop); + tree->create<double>(root / "freq/value") + .subscribe_master(boost::bind(&get_set_freq, subdev, _1)); - property<meta_range_t> freq_range_prop; - freq_range_prop.publish(boost::bind(&get_freq_range, subdev)); - tree->create(root / "freq/range", freq_range_prop); + tree->create<meta_range_t>(root / "freq/range") + .publish(boost::bind(&get_freq_range, subdev)); - property<std::string> ant_prop; - ant_prop.subscribe_master(boost::bind(&get_set_ant, subdev, _1)); - tree->create(root / "antenna/value", ant_prop); + tree->create<std::string>(root / "antenna/value") + .subscribe_master(boost::bind(&get_set_ant, subdev, _1)); - property<std::vector<std::string> > ants_prop; - ants_prop.publish(boost::bind(&get_ants, subdev)); - tree->create(root / "antenna/options", ants_prop); + tree->create<std::vector<std::string> >(root / "antenna/options") + .publish(boost::bind(&get_ants, subdev)); - property<std::string> conn_prop; - conn_prop.publish(boost::bind(&get_conn, subdev)); - tree->create(root / "connection", conn_prop); + tree->create<std::string>(root / "connection") + .publish(boost::bind(&get_conn, subdev)); - property<bool> enb_prop; - enb_prop.subscribe_master(boost::bind(&get_set_enb, subdev, _1)); - tree->create(root / "enabled", enb_prop); + tree->create<bool>(root / "enabled") + .subscribe_master(boost::bind(&get_set_enb, subdev, _1)); - property<bool> use_lo_off_prop; - use_lo_off_prop.publish(boost::bind(&get_use_lo_off, subdev)); - tree->create(root / "use_lo_offset", use_lo_off_prop); + tree->create<bool>(root / "use_lo_offset") + .publish(boost::bind(&get_use_lo_off, subdev)); - property<double> bw_prop; - bw_prop.subscribe_master(boost::bind(&get_set_bw, subdev, _1)); - tree->create(root / "bandwidth/value", bw_prop); + tree->create<double>(root / "bandwidth/value") + .subscribe_master(boost::bind(&get_set_bw, subdev, _1)); } diff --git a/host/lib/usrp2/io_impl.cpp b/host/lib/usrp2/io_impl.cpp index 9f0792d53..5ebb1609d 100644 --- a/host/lib/usrp2/io_impl.cpp +++ b/host/lib/usrp2/io_impl.cpp @@ -246,7 +246,15 @@ void usrp2_impl::io_impl::recv_pirate_loop( **********************************************************************/ void usrp2_impl::io_init(void){ - //TODO //This is a hack/fix for the lingering packet problem. + //setup rx otw type + _rx_otw_type.width = 16; + _rx_otw_type.shift = 0; + _rx_otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + + //setup tx otw type + _tx_otw_type.width = 16; + _tx_otw_type.shift = 0; + _tx_otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; //create new io impl _io_impl = UHD_PIMPL_MAKE(io_impl, (_mboard_stuff.size())); diff --git a/host/lib/usrp2/usrp2_impl.cpp b/host/lib/usrp2/usrp2_impl.cpp index cbe4a7dba..a66c4cd59 100644 --- a/host/lib/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp2/usrp2_impl.cpp @@ -341,7 +341,9 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ //////////////////////////////////////////////////////////////// _mboard_stuff[mb].clock = usrp2_clock_ctrl::make(_mboard_stuff[mb].iface); const double tick_rate = _mboard_stuff[mb].clock->get_master_clock_rate(); - property<double> tick_rate_prop(tick_rate); + property<double> tick_rate_prop; + tick_rate_prop.publish(boost::bind(&usrp2_clock_ctrl::get_master_clock_rate, _mboard_stuff[mb].clock)); + tick_rate_prop.subscribe(boost::bind(&usrp2_impl::update_tick_rate, this, _1)); _tree->create(mb_path / "tick_rate", tick_rate_prop); //////////////////////////////////////////////////////////////// @@ -428,16 +430,20 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ //TODO lots of properties to expose here for frontends //////////////////////////////////////////////////////////////// - // create dsp control objects + // create rx dsp control objects //////////////////////////////////////////////////////////////// _mboard_stuff[mb].rx_dsps.push_back(rx_dsp_core_200::make( - _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_RX_DSP0), U2_REG_SR_ADDR(SR_RX_CTRL0), USRP2_RX_SID_BASE + 0 + _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_RX_DSP0), U2_REG_SR_ADDR(SR_RX_CTRL0), USRP2_RX_SID_BASE + 0, true )); _mboard_stuff[mb].rx_dsps.push_back(rx_dsp_core_200::make( - _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_RX_DSP1), U2_REG_SR_ADDR(SR_RX_CTRL1), USRP2_RX_SID_BASE + 1 + _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_RX_DSP1), U2_REG_SR_ADDR(SR_RX_CTRL1), USRP2_RX_SID_BASE + 1, true )); for (size_t dspno = 0; dspno < _mboard_stuff[mb].rx_dsps.size(); dspno++){ _mboard_stuff[mb].rx_dsps[dspno]->set_tick_rate(tick_rate); //does not change on usrp2 + //This is a hack/fix for the lingering packet problem. + //The dsp core starts streaming briefly... now we flush + _mboard_stuff[mb].dsp_xports[dspno]->get_recv_buff(0.01).get(); //recv with timeout for lingering + _mboard_stuff[mb].dsp_xports[dspno]->get_recv_buff(0.01).get(); //recv with timeout for expected property_tree::path_type rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno); property<double> host_rate_prop, freq_prop; host_rate_prop.subscribe_master(boost::bind(&rx_dsp_core_200::set_host_rate, _mboard_stuff[mb].rx_dsps[dspno], _1)); @@ -447,6 +453,10 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ //TODO set nsamps per packet //TODO stream command issue } + + //////////////////////////////////////////////////////////////// + // create tx dsp control objects + //////////////////////////////////////////////////////////////// _mboard_stuff[mb].tx_dsp = tx_dsp_core_200::make( _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_TX_DSP), U2_REG_SR_ADDR(SR_TX_CTRL), USRP2_TX_ASYNC_SID ); diff --git a/host/tests/property_test.cpp b/host/tests/property_test.cpp index b579e5213..6c80cea70 100644 --- a/host/tests/property_test.cpp +++ b/host/tests/property_test.cpp @@ -16,7 +16,6 @@ // #include <boost/test/unit_test.hpp> -#include <uhd/property.hpp> #include <uhd/property_tree.hpp> #include <boost/bind.hpp> #include <iostream> @@ -36,50 +35,50 @@ struct setter_type{ }; BOOST_AUTO_TEST_CASE(test_prop_simple){ - uhd::property<int> prop; - prop.set(42); - BOOST_CHECK_EQUAL(prop.get(), 42); - prop.set(34); - BOOST_CHECK_EQUAL(prop.get(), 34); + uhd::property<int>::sptr prop = uhd::property<int>::make(); + prop->set(42); + BOOST_CHECK_EQUAL(prop->get(), 42); + prop->set(34); + BOOST_CHECK_EQUAL(prop->get(), 34); } BOOST_AUTO_TEST_CASE(test_prop_with_subscriber){ - uhd::property<int> prop; + uhd::property<int>::sptr prop = uhd::property<int>::make(); setter_type setter; - prop.subscribe(boost::bind(&setter_type::doit, &setter, _1)); + prop->subscribe(boost::bind(&setter_type::doit, &setter, _1)); - prop.set(42); - BOOST_CHECK_EQUAL(prop.get(), 42); + prop->set(42); + BOOST_CHECK_EQUAL(prop->get(), 42); BOOST_CHECK_EQUAL(setter._x, 42); - prop.set(34); - BOOST_CHECK_EQUAL(prop.get(), 34); + prop->set(34); + BOOST_CHECK_EQUAL(prop->get(), 34); BOOST_CHECK_EQUAL(setter._x, 34); } BOOST_AUTO_TEST_CASE(test_prop_with_coercion){ - uhd::property<int> prop; + uhd::property<int>::sptr prop = uhd::property<int>::make(); setter_type setter; - prop.subscribe(boost::bind(&setter_type::doit, &setter, _1)); + prop->subscribe(boost::bind(&setter_type::doit, &setter, _1)); coercer_type coercer; - prop.subscribe_master(boost::bind(&coercer_type::doit, &coercer, _1)); + prop->subscribe_master(boost::bind(&coercer_type::doit, &coercer, _1)); - prop.set(42); - BOOST_CHECK_EQUAL(prop.get(), 40); + prop->set(42); + BOOST_CHECK_EQUAL(prop->get(), 40); BOOST_CHECK_EQUAL(setter._x, 40); - prop.set(34); - BOOST_CHECK_EQUAL(prop.get(), 32); + prop->set(34); + BOOST_CHECK_EQUAL(prop->get(), 32); BOOST_CHECK_EQUAL(setter._x, 32); } BOOST_AUTO_TEST_CASE(test_prop_tree){ uhd::property_tree::sptr tree = uhd::property_tree::make(); - tree->create("/test/prop0", uhd::property<int>()); + tree->create<int>("/test/prop0"); tree->create<int>("/test/prop1"); BOOST_CHECK(tree->exists("/test")); @@ -89,6 +88,9 @@ BOOST_AUTO_TEST_CASE(test_prop_tree){ tree->access<int>("/test/prop0").set(42); tree->access<int>("/test/prop1").set(34); + BOOST_CHECK_EQUAL(tree->access<int>("/test/prop0").get(), 42); + BOOST_CHECK_EQUAL(tree->access<int>("/test/prop1").get(), 34); + tree->remove("/test/prop0"); BOOST_CHECK(not tree->exists("/test/prop0")); BOOST_CHECK(tree->exists("/test/prop1")); |