mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
rfnoc: Make edge comparison more flexible
This allows to compare graph edges without also comparing their properties. If an edge goes from node A, port X to node B, port Y, then it might also carry properties (e.g., is it a back-edge) that may not be relevant for the comparison. This is relevant when finding edges that should be removed (e.g., in a disconnect() call). The way this change is implemented it doesn't break existing code. There is a new API call graph_edge_t::is_equal() which can take a new flag to make comparisons more or less strict. The existing operator==() is unchanged in behaviour. Co-authored-by: Marian Koop <marian.koop@ni.com>
This commit is contained in:
parent
a4b4efd07c
commit
b1923d8d40
@ -55,20 +55,30 @@ struct UHD_API graph_edge_t
|
||||
//are not used for sorting the graph as a DAG.
|
||||
bool is_forward_edge = true;
|
||||
|
||||
//! Equality operator: Compare two edges if they match, including edge
|
||||
// properties.
|
||||
bool operator==(const graph_edge_t& rhs) const
|
||||
{
|
||||
return std::tie(src_blockid,
|
||||
src_port,
|
||||
dst_blockid,
|
||||
dst_port,
|
||||
edge,
|
||||
is_forward_edge)
|
||||
== std::tie(rhs.src_blockid,
|
||||
rhs.src_port,
|
||||
rhs.dst_blockid,
|
||||
rhs.dst_port,
|
||||
rhs.edge,
|
||||
rhs.is_forward_edge);
|
||||
return is_equal(rhs, true);
|
||||
}
|
||||
|
||||
/*! Equality comparison of two edges.
|
||||
*
|
||||
* If \p match_properties is false, this compares two edges to test if they
|
||||
* have the same direction, source port, and destination port.
|
||||
* If \p match_properties is true, then it also tests if all the edge
|
||||
* properties match (edge type, back-edge).
|
||||
*
|
||||
* \returns true if edges match.
|
||||
*/
|
||||
bool is_equal(const graph_edge_t& rhs, const bool match_properties = false) const
|
||||
{
|
||||
return (std::tie(src_blockid, src_port, dst_blockid, dst_port)
|
||||
== std::tie(
|
||||
rhs.src_blockid, rhs.src_port, rhs.dst_blockid, rhs.dst_port))
|
||||
&& (match_properties ? (std::tie(edge, is_forward_edge)
|
||||
== std::tie(rhs.edge, rhs.is_forward_edge))
|
||||
: true);
|
||||
}
|
||||
|
||||
//! Return a string representation of the connection
|
||||
|
||||
Loading…
Reference in New Issue
Block a user