diff options
author | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-05-19 14:16:23 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-05-28 14:49:32 -0500 |
commit | cb99b720eee76dcf83ac89a2107f516443372b7f (patch) | |
tree | d76a56c0de7f13db13a831d5af1ec054acacbb55 /host/include | |
parent | e063e17a1f9a182eba7b8babd126ba34a8af79e0 (diff) | |
download | uhd-cb99b720eee76dcf83ac89a2107f516443372b7f.tar.gz uhd-cb99b720eee76dcf83ac89a2107f516443372b7f.tar.bz2 uhd-cb99b720eee76dcf83ac89a2107f516443372b7f.zip |
rfnoc: Add USE_MAP prop/action forwarding policy
This commit adds a new forwarding policy for properties and actions,
USE_MAP. This forwarding policy causes the node to consult a
user-provided map to determine how to forward the property or action.
The map's key is the source edge of the incoming property or action,
while the value is a list of destination edges to which the property
should be propagated or action should be forwarded. It allows clients to
construct sophisticated forwarding behaviors for specialized blocks,
such as a split stream block that needs to forward properties and
actions only to specific output edges based on the incoming edge.
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/rfnoc/node.hpp | 57 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/res_source_info.hpp | 5 |
2 files changed, 61 insertions, 1 deletions
diff --git a/host/include/uhd/rfnoc/node.hpp b/host/include/uhd/rfnoc/node.hpp index a907de5a4..b26546643 100644 --- a/host/include/uhd/rfnoc/node.hpp +++ b/host/include/uhd/rfnoc/node.hpp @@ -38,6 +38,8 @@ public: using resolve_callback_t = std::function<void(void)>; using action_handler_t = std::function<void(const res_source_info&, action_info::sptr)>; + using forwarding_map_t = + std::unordered_map<res_source_info, std::vector<res_source_info>>; //! Types of property/action forwarding for those not defined by the block itself enum class forwarding_policy_t { @@ -53,7 +55,9 @@ public: //! Forward the property to all ports ONE_TO_ALL, //! Property propagation ends here - DROP + DROP, + //! Forward the property based on a client-provided map + USE_MAP }; static const size_t ANY_PORT = size_t(~0); @@ -273,6 +277,27 @@ protected: void set_prop_forwarding_policy( forwarding_policy_t policy, const std::string& prop_id = ""); + /*! Specify a table that maps how a property should be forwarded + * + * Whenever this node is asked to handle a property that is not registered, + * and the forwarding policy for the particular property is set to + * USE_MAP, the node will consult a user-provided map to determine what + * to do with the property. The map's keys are the source edges for the + * incoming property and the value associated with each key is a vector of + * destination edges to which the property should be propagated. + * + * If there is no key in the map matching an incoming property's source + * edge, or if the value of the key is the empty vector, the property is + * dropped and not propagated further. + * + * The following conditions will generate exceptions at property + * propagation time: + * - Any value in the destination vector represents a non-existent port + * + * \param map The map describing how properties should be propagated + */ + void set_prop_forwarding_map(const forwarding_map_t& map); + /*! Set a specific property that belongs to this block. * * This is like set_property(), but it also allows setting edge properties. @@ -342,6 +367,30 @@ protected: void set_action_forwarding_policy( forwarding_policy_t policy, const std::string& action_key = ""); + /*! Specify a table that maps how an action should be forwarded + * + * Whenever this node is asked to handle an action that is not registered, + * and the forwarding policy for the particular action is set to + * USE_MAP, the node will consult a user-provided map to determine what + * to do with the action. The map's keys are the source edges for the + * incoming action and the value associated with each key is a vector of + * destination edges to which the action should be forwarded. + * + * incoming action and the value is a vector of destination edges to + * which the action should be forwarded. + * + * If there is no key in the map matching an incoming action's source + * edge, or if the value of the key is the empty vector, the action is + * dropped and not forwarded further. + * + * The following conditions will generate exceptions at action + * forwarding time: + * - Any value in the destination vector represents a non-existent port + * + * \param map The map describing how actions should be forwarded + */ + void set_action_forwarding_map(const forwarding_map_t& map); + /*! Post an action to an up- or downstream node in the graph. * * If the action is posted to an edge which is not connected, the action @@ -604,6 +653,9 @@ private: std::unordered_map<std::string, forwarding_policy_t> _prop_fwd_policies{ {"", forwarding_policy_t::ONE_TO_ONE}}; + //! Map describing how incoming properties should be propagated for USE_MAP + forwarding_map_t _prop_fwd_map; + /************************************************************************** * Action-related attributes *************************************************************************/ @@ -622,6 +674,9 @@ private: action_handler_t _post_action_cb = [](const res_source_info&, action_info::sptr) { /* nop */ }; + //! Map describing how incoming actions should be forwarded for USE_MAP + forwarding_map_t _action_fwd_map; + /************************************************************************** * Other attributes *************************************************************************/ diff --git a/host/include/uhd/rfnoc/res_source_info.hpp b/host/include/uhd/rfnoc/res_source_info.hpp index 7174c95e4..05d92e5bf 100644 --- a/host/include/uhd/rfnoc/res_source_info.hpp +++ b/host/include/uhd/rfnoc/res_source_info.hpp @@ -46,6 +46,11 @@ struct res_source_info return rhs.type == type && rhs.instance == instance; } + bool operator!=(const res_source_info& rhs) const + { + return !(*this == rhs); + } + //! Returns a string representation of the source std::string to_string() const { |