aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-06-29 13:57:06 -0700
committerJosh Blum <josh@joshknows.com>2011-06-29 13:57:06 -0700
commitbc8aaf3952f1c192030d1c9a0b6ddcbe14d9c062 (patch)
tree3ab8a27c2ccd0240925cde1c5a23f8b99af0c504 /host/include
parentd38757f4656028800e393c91bf3fec1986eb0200 (diff)
downloaduhd-bc8aaf3952f1c192030d1c9a0b6ddcbe14d9c062.tar.gz
uhd-bc8aaf3952f1c192030d1c9a0b6ddcbe14d9c062.tar.bz2
uhd-bc8aaf3952f1c192030d1c9a0b6ddcbe14d9c062.zip
uhd: misc tweaks and also msvc compile
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/property_tree.hpp9
-rw-r--r--host/include/uhd/property_tree.ipp10
2 files changed, 14 insertions, 5 deletions
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 <typename T> class UHD_API property : boost::noncopyable{
+template <typename T> class property : boost::noncopyable{
public:
typedef boost::function<void(const T &)> subscriber_type;
typedef boost::function<T(void)> 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 <typename T> class UHD_API property_impl : public property<T>{
+template <typename T> class property_impl : public property<T>{
public:
property<T> &coerce(const typename property<T>::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<typename property<T>::subscriber_type> _subscribers;
typename property<T>::publisher_type _publisher;