From bc8aaf3952f1c192030d1c9a0b6ddcbe14d9c062 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 29 Jun 2011 13:57:06 -0700 Subject: uhd: misc tweaks and also msvc compile --- host/include/uhd/property_tree.hpp | 9 ++++++++- host/include/uhd/property_tree.ipp | 10 ++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/property_tree.hpp b/host/include/uhd/property_tree.hpp index b20f3b779..c41a129b1 100644 --- a/host/include/uhd/property_tree.hpp +++ b/host/include/uhd/property_tree.hpp @@ -31,7 +31,7 @@ namespace uhd{ * A templated property interface for holding a value * and registering callbacks when that value changes. */ -template class UHD_API property : boost::noncopyable{ +template class property : boost::noncopyable{ public: typedef boost::function subscriber_type; typedef boost::function publisher_type; @@ -89,6 +89,13 @@ public: * \return the current value in the property */ virtual T get(void) const = 0; + + /*! + * A property is empty if it has never been set. + * A property with a publisher is never empty. + * \return true if the property is empty + */ + virtual bool empty(void) const = 0; }; /*! diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp index 58ee2339c..868cba475 100644 --- a/host/include/uhd/property_tree.ipp +++ b/host/include/uhd/property_tree.ipp @@ -27,7 +27,7 @@ **********************************************************************/ namespace uhd{ namespace /*anon*/{ -template class UHD_API property_impl : public property{ +template class property_impl : public property{ public: property &coerce(const typename property::coercer_type &coercer){ @@ -59,12 +59,14 @@ public: } T get(void) const{ - if (_publisher.empty() and _value.get() == NULL) throw uhd::runtime_error( - "Called get() on property with an uninitialized value" - ); + if (empty()) throw uhd::runtime_error("Cannot get() on an empty property"); return _publisher.empty()? *_value : _publisher(); } + bool empty(void) const{ + return _publisher.empty() and _value.get() == NULL; + } + private: std::vector::subscriber_type> _subscribers; typename property::publisher_type _publisher; -- cgit v1.2.3