USRP Hardware Driver and USRP Manual Version: 20250718.0.git40403b7c.fc43
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
10#include <uhd/rfnoc/node.hpp>
12#include <functional>
13
14namespace 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.
28{
29public:
31
35 void init_props(node_t* node)
36 {
37 node->init_props();
38 }
39
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
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 */
82 {
83 node->clear_resolve_all_callback();
84 }
85
92 {
93 node->set_graph_mutex_callback(std::move(mutex));
94 }
95
102 {
103 node->clear_graph_mutex_callback();
104 }
105
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
121 {
122 node->set_post_action_callback(std::move(post_handler));
123 }
124
130 node_t* node, const res_source_info& port_info, action_info::sptr action)
131 {
132 node->receive_action(port_info, action);
133 }
134
140 node_t* node, const res_source_info& edge_info, action_info::sptr action)
141 {
142 node->post_action(edge_info, action);
143 }
144
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 */
Special class which may access nodes.
Definition node_accessor.hpp:28
void clear_graph_mutex_callback(node_t *node)
Definition node_accessor.hpp:101
void resolve_props(node_t *node)
Definition node_accessor.hpp:44
void send_action(node_t *node, const res_source_info &port_info, action_info::sptr action)
Definition node_accessor.hpp:129
void set_post_action_callback(node_t *node, node_t::action_handler_t &&post_handler)
Definition node_accessor.hpp:120
void init_props(node_t *node)
Definition node_accessor.hpp:35
node_t::prop_ptrs_t prop_ptrs_t
Definition node_accessor.hpp:30
node_t::prop_ptrs_t filter_props(node_t *node, PredicateType &&predicate)
Definition node_accessor.hpp:54
void clean_props(node_t *node)
Definition node_accessor.hpp:63
void set_resolve_all_callback(node_t *node, node_t::resolve_callback_t &&resolver)
Definition node_accessor.hpp:72
void forward_edge_property(node_t *dst_node, const size_t dst_port, property_base_t *incoming_prop)
Definition node_accessor.hpp:110
void shutdown(node_t *node)
Definition node_accessor.hpp:160
void set_graph_mutex_callback(node_t *node, node_t::graph_mutex_callback_t &&mutex)
Definition node_accessor.hpp:91
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
void clear_resolve_all_callback(node_t *node)
Definition node_accessor.hpp:81
void post_action(node_t *node, const res_source_info &edge_info, action_info::sptr action)
Definition node_accessor.hpp:139
Definition node.hpp:35
std::vector< property_base_t * > prop_ptrs_t
Definition node.hpp:220
std::function< void(void)> resolve_callback_t
Definition node.hpp:38
void post_action(const res_source_info &edge_info, action_info::sptr action)
std::function< void(const res_source_info &, action_info::sptr)> action_handler_t
Definition node.hpp:40
virtual bool check_topology(const std::vector< size_t > &connected_inputs, const std::vector< size_t > &connected_outputs)
virtual void shutdown()
std::function< std::recursive_mutex &(void)> graph_mutex_callback_t
Definition node.hpp:39
Definition property.hpp:26
Definition actions.hpp:24
Definition build_info.hpp:12
std::shared_ptr< action_info > sptr
Definition actions.hpp:38
Definition res_source_info.hpp:18