diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-05-30 16:08:43 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:20 -0800 |
commit | 31449a44699b6484442c91394e8ff14e22cea246 (patch) | |
tree | bf2a1aa94b08990794bd71184ccb6a395276085b /host/include | |
parent | 0347974ae3cc36bc0cadf4add080f5ea8781a295 (diff) | |
download | uhd-31449a44699b6484442c91394e8ff14e22cea246.tar.gz uhd-31449a44699b6484442c91394e8ff14e22cea246.tar.bz2 uhd-31449a44699b6484442c91394e8ff14e22cea246.zip |
rfnoc: node: Add API to query and set edge properties
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/rfnoc/node.hpp | 30 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/node.ipp | 27 |
2 files changed, 50 insertions, 7 deletions
diff --git a/host/include/uhd/rfnoc/node.hpp b/host/include/uhd/rfnoc/node.hpp index ffbfc3319..09ae76e9a 100644 --- a/host/include/uhd/rfnoc/node.hpp +++ b/host/include/uhd/rfnoc/node.hpp @@ -242,6 +242,36 @@ protected: void set_prop_forwarding_policy( forwarding_policy_t policy, const std::string& prop_id = ""); + /*! Set a specific property that belongs to this block. + * + * This is like set_property(), but it also allows setting edge properties. + * All comments from set_property() still apply. + * + * \param prop_data_t The data type of the property + * \param id The identifier of the property to write. To find out which + * values of \p id are valid, call get_property_ids() + * \param val The new value of the property. + * \param src_info Source info of the property + */ + template <typename prop_data_t> + void set_property( + const std::string& id, const prop_data_t& val, const res_source_info& src_info); + + /*! Get the value of a property. + * + * This is like get_property(), but it also allows reading edge properties. + * All comments from get_property() still apply. + * + * \param prop_data_t The data type of the property + * \param id The identifier of the property to write. + * \param src_info Source info of this property + * \return The value of the property. + * \throws uhd::lookup_error if the property can't be found. + */ + template <typename prop_data_t> + const prop_data_t& get_property( + const std::string& id, const res_source_info& src_info) /* mutable */; + /****************************************** * Internal action forwarding ******************************************/ diff --git a/host/include/uhd/rfnoc/node.ipp b/host/include/uhd/rfnoc/node.ipp index 62db98243..339b055fd 100644 --- a/host/include/uhd/rfnoc/node.ipp +++ b/host/include/uhd/rfnoc/node.ipp @@ -21,7 +21,7 @@ uhd::rfnoc::property_t<prop_data_t>* _assert_prop( // First check if the pointer is valid at all: if (prop_base_ptr == nullptr) { throw uhd::lookup_error( - str(boost::format("[%s] Unknown user property: `%s'") % node_id % prop_id)); + str(boost::format("[%s] Unknown property: `%s'") % node_id % prop_id)); } // Next, check if we can cast the pointer to the desired type: @@ -30,7 +30,7 @@ uhd::rfnoc::property_t<prop_data_t>* _assert_prop( if (!prop_ptr) { throw uhd::type_error(str( boost::format( - "[%s] Found user property `%s', but could not cast to requested type `%s'!") + "[%s] Found property `%s', but could not cast to requested type `%s'!") % node_id % prop_id % boost::units::detail::demangle(typeid(prop_data_t).name()) )); } @@ -47,7 +47,21 @@ void node_t::set_property( const std::string& id, const prop_data_t& val, const size_t instance) { res_source_info src_info{res_source_info::USER, instance}; - UHD_LOG_TRACE(get_unique_id(), "Setting property `" << id << "`"); + set_property<prop_data_t>(id, val, src_info); +} + +template <typename prop_data_t> +const prop_data_t& node_t::get_property(const std::string& id, const size_t instance) +{ + res_source_info src_info{res_source_info::USER, instance}; + return get_property<prop_data_t>(id, src_info); +} + +template <typename prop_data_t> +void node_t::set_property( + const std::string& id, const prop_data_t& val, const res_source_info& src_info) +{ + RFNOC_LOG_TRACE("Setting property " << id << "@" << src_info.to_string()); auto prop_ptr = _assert_prop<prop_data_t>(_find_property(src_info, id), get_unique_id(), id); { @@ -61,10 +75,10 @@ void node_t::set_property( } template <typename prop_data_t> -const prop_data_t& node_t::get_property(const std::string& id, const size_t instance) +const prop_data_t& node_t::get_property( + const std::string& id, const res_source_info& src_info) { - res_source_info src_info{res_source_info::USER, instance}; - + RFNOC_LOG_TRACE("Getting property " << id << "@" << src_info.to_string()); // First, trigger a property resolution to make sure this property is // updated (if necessary) before reading it out resolve_all(); @@ -75,7 +89,6 @@ const prop_data_t& node_t::get_property(const std::string& id, const size_t inst return prop_ptr->get(); } - }} /* namespace uhd::rfnoc */ #endif /* INCLUDED_LIBUHD_RFNOC_NODE_IPP */ |