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/include/uhd/property_tree.hpp | 9 ++------- host/include/uhd/property_tree.ipp | 22 +++++----------------- 2 files changed, 7 insertions(+), 24 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/property_tree.hpp b/host/include/uhd/property_tree.hpp index 630e86bba..63cd76a56 100644 --- a/host/include/uhd/property_tree.hpp +++ b/host/include/uhd/property_tree.hpp @@ -19,7 +19,6 @@ #define INCLUDED_UHD_PROPERTY_TREE_HPP #include -#include #include #include #include @@ -34,14 +33,10 @@ namespace uhd{ */ template class UHD_API property : boost::noncopyable{ public: - typedef boost::shared_ptr sptr; typedef boost::function subscriber_type; typedef boost::function publisher_type; typedef boost::function 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. @@ -107,10 +102,10 @@ public: protected: //! Internal create property with wild-card type - virtual void _create(const path_type &path, const boost::any &prop) = 0; + virtual void _create(const path_type &path, const boost::shared_ptr &prop) = 0; //! Internal access property with wild-card type - virtual boost::any &_access(const path_type &path) = 0; + virtual boost::shared_ptr &_access(const path_type &path) = 0; }; diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp index e4520df58..1c61d4937 100644 --- a/host/include/uhd/property_tree.ipp +++ b/host/include/uhd/property_tree.ipp @@ -18,15 +18,14 @@ #ifndef INCLUDED_UHD_PROPERTY_TREE_IPP #define INCLUDED_UHD_PROPERTY_TREE_IPP -#include #include +#include #include /*********************************************************************** * Implement templated property impl **********************************************************************/ -namespace uhd{ -namespace /*anon*/{ +namespace uhd{ namespace /*anon*/{ template class UHD_API property_impl : public property{ public: @@ -71,13 +70,7 @@ private: boost::any _value; //any type so we can assign structs w/ const members }; -} //namespace /*anon*/ - -template typename property::sptr property::make(void){ - return sptr(new property_impl()); -} - -} //namespace uhd +}} //namespace uhd::/*anon*/ /*********************************************************************** * Implement templated methods for the property tree @@ -85,17 +78,12 @@ template typename property::sptr property::make(void){ namespace uhd{ template property &property_tree::create(const path_type &path){ - this->_create(path, property::make()); + this->_create(path, typename boost::shared_ptr >(new property_impl())); return this->access(path); } template property &property_tree::access(const path_type &path){ - try{ - return *boost::any_cast::sptr>(this->_access(path)); - } - catch(const boost::bad_any_cast &){ - throw uhd::type_error("Cannot cast the property at: " + path.string()); - } + return *boost::static_pointer_cast >(this->_access(path)); } } //namespace uhd -- cgit v1.2.3