| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
node_accessor.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/rfnoc/actions.hpp>
10#include <uhd/rfnoc/node.hpp>
11#include <uhd/rfnoc/res_source_info.hpp>
12#include <functional>
13
14 namespace uhd { namespace rfnoc {
15
17//
18// For the sake of property resolution, we require access to certain private
19// members of nodes. Instead of giving everyone access to everything, we create
20// this accessor class to allow by-passing the access control.
21//
22// This class is not meant to be used by users of the RFNoC API, but in certain
23// corner cases, it may be useful for RFNoC block developers. One main use case
24// is unit tests, where we need to access the internals of nodes to test their
25// functionality (e.g., by reading hidden state). Is it not considered good
26// practice to use this class in production code, as it breaks encapsulation.
27 class node_accessor_t
28{
29 public:
30 using prop_ptrs_t = node_t::prop_ptrs_t;
31
35 void init_props(node_t* node)
36 {
37 node->init_props();
38 }
39
44 void resolve_props(node_t* node)
45 {
46 node->resolve_props();
47 }
48
53 template <typename PredicateType>
54 node_t::prop_ptrs_t filter_props(node_t* node, PredicateType&& predicate)
55 {
56 return node->filter_props(std::forward<PredicateType>(predicate));
57 }
58
63 void clean_props(node_t* node)
64 {
65 node->clean_props();
66 }
67
72 void set_resolve_all_callback(node_t* node, node_t::resolve_callback_t&& resolver)
73 {
74 node->set_resolve_all_callback(std::move(resolver));
75 }
76
77 /* Restore the resolver callback to its default implementation
78 *
79 * See node_t::clear_resolve_all_callback() for details.
80 */
81 void clear_resolve_all_callback(node_t* node)
82 {
83 node->clear_resolve_all_callback();
84 }
85
91 void set_graph_mutex_callback(node_t* node, node_t::graph_mutex_callback_t&& mutex)
92 {
93 node->set_graph_mutex_callback(std::move(mutex));
94 }
95
101 void clear_graph_mutex_callback(node_t* node)
102 {
103 node->clear_graph_mutex_callback();
104 }
105
110 void forward_edge_property(
111 node_t* dst_node, const size_t dst_port, property_base_t* incoming_prop)
112 {
113 dst_node->forward_edge_property(incoming_prop, dst_port);
114 }
115
120 void set_post_action_callback(node_t* node, node_t::action_handler_t&& post_handler)
121 {
122 node->set_post_action_callback(std::move(post_handler));
123 }
124
129 void send_action(
130 node_t* node, const res_source_info& port_info, action_info::sptr action)
131 {
132 node->receive_action(port_info, action);
133 }
134
139 void post_action(
140 node_t* node, const res_source_info& edge_info, action_info::sptr action)
141 {
142 node->post_action(edge_info, action);
143 }
144
149 bool check_topology(node_t* node,
150 const std::vector<size_t>& connected_inputs,
151 const std::vector<size_t>& connected_outputs)
152 {
153 return node->check_topology(connected_inputs, connected_outputs);
154 }
155
160 void shutdown(node_t* node)
161 {
162 node->shutdown();
163 }
164};
165
166
167}} /* namespace uhd::rfnoc */
actions.hpp
uhd::rfnoc::node_accessor_t
Special class which may access nodes.
Definition node_accessor.hpp:28
uhd::rfnoc::node_accessor_t::clear_graph_mutex_callback
void clear_graph_mutex_callback(node_t *node)
Definition node_accessor.hpp:101
uhd::rfnoc::node_accessor_t::resolve_props
void resolve_props(node_t *node)
Definition node_accessor.hpp:44
uhd::rfnoc::node_accessor_t::send_action
void send_action(node_t *node, const res_source_info &port_info, action_info::sptr action)
Definition node_accessor.hpp:129
uhd::rfnoc::node_accessor_t::set_post_action_callback
void set_post_action_callback(node_t *node, node_t::action_handler_t &&post_handler)
Definition node_accessor.hpp:120
uhd::rfnoc::node_accessor_t::init_props
void init_props(node_t *node)
Definition node_accessor.hpp:35
uhd::rfnoc::node_accessor_t::prop_ptrs_t
node_t::prop_ptrs_t prop_ptrs_t
Definition node_accessor.hpp:30
uhd::rfnoc::node_accessor_t::filter_props
node_t::prop_ptrs_t filter_props(node_t *node, PredicateType &&predicate)
Definition node_accessor.hpp:54
uhd::rfnoc::node_accessor_t::clean_props
void clean_props(node_t *node)
Definition node_accessor.hpp:63
uhd::rfnoc::node_accessor_t::set_resolve_all_callback
void set_resolve_all_callback(node_t *node, node_t::resolve_callback_t &&resolver)
Definition node_accessor.hpp:72
uhd::rfnoc::node_accessor_t::forward_edge_property
void forward_edge_property(node_t *dst_node, const size_t dst_port, property_base_t *incoming_prop)
Definition node_accessor.hpp:110
uhd::rfnoc::node_accessor_t::shutdown
void shutdown(node_t *node)
Definition node_accessor.hpp:160
uhd::rfnoc::node_accessor_t::set_graph_mutex_callback
void set_graph_mutex_callback(node_t *node, node_t::graph_mutex_callback_t &&mutex)
Definition node_accessor.hpp:91
uhd::rfnoc::node_accessor_t::check_topology
bool check_topology(node_t *node, const std::vector< size_t > &connected_inputs, const std::vector< size_t > &connected_outputs)
Definition node_accessor.hpp:149
uhd::rfnoc::node_accessor_t::clear_resolve_all_callback
void clear_resolve_all_callback(node_t *node)
Definition node_accessor.hpp:81
uhd::rfnoc::node_accessor_t::post_action
void post_action(node_t *node, const res_source_info &edge_info, action_info::sptr action)
Definition node_accessor.hpp:139
uhd::rfnoc::node_t
Definition node.hpp:35
uhd::rfnoc::node_t::prop_ptrs_t
std::vector< property_base_t * > prop_ptrs_t
Definition node.hpp:220
uhd::rfnoc::node_t::resolve_callback_t
std::function< void(void)> resolve_callback_t
Definition node.hpp:38
uhd::rfnoc::node_t::post_action
void post_action(const res_source_info &edge_info, action_info::sptr action)
uhd::rfnoc::node_t::action_handler_t
std::function< void(const res_source_info &, action_info::sptr)> action_handler_t
Definition node.hpp:40
uhd::rfnoc::node_t::check_topology
virtual bool check_topology(const std::vector< size_t > &connected_inputs, const std::vector< size_t > &connected_outputs)
uhd::rfnoc::node_t::shutdown
virtual void shutdown()
uhd::rfnoc::node_t::graph_mutex_callback_t
std::function< std::recursive_mutex &(void)> graph_mutex_callback_t
Definition node.hpp:39
uhd::rfnoc::property_base_t
Definition property.hpp:26
uhd::rfnoc
Definition actions.hpp:24
uhd
Definition build_info.hpp:12
node.hpp
res_source_info.hpp
uhd::rfnoc::action_info::sptr
std::shared_ptr< action_info > sptr
Definition actions.hpp:38
uhd::rfnoc::res_source_info
Definition res_source_info.hpp:18