USRP Hardware Driver and Device Manual  Version: 4.10.0.0-0-g2af4ddb9
UHD and USRP Manual
graph_edge.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2019 Ettus Research, a National Instruments Brand
3 //
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 //
6 
7 #pragma once
8 
9 #include <uhd/config.hpp>
10 #include <cstdint>
11 #include <string>
12 #include <tuple>
13 
14 namespace uhd { namespace rfnoc {
15 
24 {
25  enum edge_t : uint32_t {
29  TX_STREAM
30  };
31 
32  graph_edge_t() = default;
33 
34  graph_edge_t(const size_t src_port_,
35  const size_t dst_port_,
36  const edge_t edge_,
37  const bool fwd_edge)
38  : src_port(src_port_), dst_port(dst_port_), edge(edge_), is_forward_edge(fwd_edge)
39  {
40  }
41 
43  std::string src_blockid;
45  size_t src_port = 0;
47  std::string dst_blockid;
49  size_t dst_port = 0;
51  edge_t edge = DYNAMIC;
53  // are not used for sorting the graph as a DAG.
54  bool is_forward_edge = true;
55 
57  // properties.
58  bool operator==(const graph_edge_t& rhs) const
59  {
60  return is_equal(rhs, true);
61  }
62 
72  bool is_equal(const graph_edge_t& rhs, const bool match_properties = false) const
73  {
74  return (std::tie(src_blockid, src_port, dst_blockid, dst_port)
75  == std::tie(
76  rhs.src_blockid, rhs.src_port, rhs.dst_blockid, rhs.dst_port))
77  && (match_properties ? (std::tie(edge, is_forward_edge)
78  == std::tie(rhs.edge, rhs.is_forward_edge))
79  : true);
80  }
81 
83  std::string to_string() const
84  {
85  return src_blockid + ":" + std::to_string(src_port)
86  + (edge == STATIC ? "==>" : "-->") + dst_blockid + ":"
87  + std::to_string(dst_port);
88  }
89 };
90 
91 
92 }} /* namespace uhd::rfnoc */
#define UHD_API
Definition: config.h:87
Definition: build_info.hpp:12
Definition: graph_edge.hpp:24
std::string to_string() const
Return a string representation of the connection.
Definition: graph_edge.hpp:83
bool is_equal(const graph_edge_t &rhs, const bool match_properties=false) const
Definition: graph_edge.hpp:72
std::string dst_blockid
The ID of the destination block for this edge.
Definition: graph_edge.hpp:47
bool is_forward_edge
When false, the framework will assume this is a back-edge. Back-edges.
Definition: graph_edge.hpp:54
std::string src_blockid
The ID of the source block for this edge.
Definition: graph_edge.hpp:43
edge_t edge
The type of edge.
Definition: graph_edge.hpp:51
graph_edge_t(const size_t src_port_, const size_t dst_port_, const edge_t edge_, const bool fwd_edge)
Definition: graph_edge.hpp:34
edge_t
Definition: graph_edge.hpp:25
@ DYNAMIC
A user (dynamic) connection between two blocks in the FPGA.
Definition: graph_edge.hpp:27
@ STATIC
A static connection between two blocks in the FPGA.
Definition: graph_edge.hpp:26
@ RX_STREAM
A connection from an FPGA block to a software RX streamer.
Definition: graph_edge.hpp:28
size_t dst_port
The port number of the destination block for this edge.
Definition: graph_edge.hpp:49
bool operator==(const graph_edge_t &rhs) const
Equality operator: Compare two edges if they match, including edge.
Definition: graph_edge.hpp:58
size_t src_port
The port number of the source block for this edge.
Definition: graph_edge.hpp:45