From d2f79c07281604c1b48ec81f1cdb2754e97bbe65 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 28 Jun 2011 21:26:28 -0700 Subject: uhd: added properties unit tests, use shared ptr in tree --- host/lib/property_tree.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'host/lib') diff --git a/host/lib/property_tree.cpp b/host/lib/property_tree.cpp index 4fbdbad12..4a0b1b061 100644 --- a/host/lib/property_tree.cpp +++ b/host/lib/property_tree.cpp @@ -61,7 +61,7 @@ public: return node->keys(); } - void _create(const path_type &path, const boost::any &prop){ + void _create(const path_type &path, const boost::shared_ptr &prop){ boost::mutex::scoped_lock lock(_mutex); node_type *node = &_root; @@ -72,7 +72,7 @@ public: node->prop = prop; } - boost::any &_access(const path_type &path){ + boost::shared_ptr &_access(const path_type &path){ boost::mutex::scoped_lock lock(_mutex); node_type *node = &_root; @@ -80,6 +80,7 @@ public: if (not node->has_key(leaf)) throw_path_not_found(path); node = &(*node)[leaf]; } + if (node->prop.get() == NULL) throw uhd::type_error("Uninitialized property at: " + path.string()); return node->prop; } @@ -89,7 +90,7 @@ private: } struct node_type : uhd::dict{ - boost::any prop; + boost::shared_ptr prop; } _root; boost::mutex _mutex; -- cgit v1.2.3