diff options
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/rfnoc/dirtifier.hpp | 5 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/property.hpp | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/dirtifier.hpp b/host/include/uhd/rfnoc/dirtifier.hpp index e31b26595..7999df021 100644 --- a/host/include/uhd/rfnoc/dirtifier.hpp +++ b/host/include/uhd/rfnoc/dirtifier.hpp @@ -46,6 +46,11 @@ public: //! Always dirty, so this can be called as often as we like void force_dirty() {} + void set_from_str(const std::string&) + { + throw uhd::runtime_error("Dirtifier property can never be set!"); + } + private: //! This property cannot be marked clean, but nothing happens if you try void mark_clean() {} diff --git a/host/include/uhd/rfnoc/property.hpp b/host/include/uhd/rfnoc/property.hpp index d01613c58..efe4deb1d 100644 --- a/host/include/uhd/rfnoc/property.hpp +++ b/host/include/uhd/rfnoc/property.hpp @@ -9,6 +9,7 @@ #include <uhd/exception.hpp> #include <uhd/rfnoc/res_source_info.hpp> +#include <uhd/utils/cast.hpp> #include <uhd/utils/dirty_tracked.hpp> #include <memory> #include <string> @@ -98,6 +99,16 @@ public: virtual void force_dirty() = 0; + /*! Set this property's value using a string + * + * This requires the underlying property type to be convertible from a + * string. + * + * \throws uhd::runtime_error if the underlying type has no conversion from + * a string + */ + virtual void set_from_str(const std::string& new_val_str) = 0; + private: friend class prop_accessor_t; @@ -175,6 +186,16 @@ public: new property_t<data_t>(get_id(), get(), new_src_info)); } + void set_from_str(const std::string& new_val_str) + { + try { + set(uhd::cast::from_str<data_t>(new_val_str)); + } catch (uhd::runtime_error& ex) { + throw uhd::runtime_error( + std::string("Property ") + get_id() + ":" + ex.what()); + } + } + //! Returns the source info for the property // const res_source_info& get_src_info() const = 0; |