Loading...
Searching...
No Matches
node_accessor.hpp
Go to the documentation of this file.
//
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/rfnoc/actions.hpp>
#include <uhd/rfnoc/node.hpp>
#include <uhd/rfnoc/res_source_info.hpp>
#include <functional>
namespace uhd { namespace rfnoc {
//
// For the sake of property resolution, we require access to certain private
// members of nodes. Instead of giving everyone access to everything, we create
// this accessor class to allow by-passing the access control.
//
// This class is not meant to be used by users of the RFNoC API, but in certain
// corner cases, it may be useful for RFNoC block developers. One main use case
// is unit tests, where we need to access the internals of nodes to test their
// functionality (e.g., by reading hidden state). Is it not considered good
// practice to use this class in production code, as it breaks encapsulation.
class node_accessor_t
{
public:
using prop_ptrs_t = node_t::prop_ptrs_t;
void init_props(node_t* node)
{
node->init_props();
}
void resolve_props(node_t* node)
{
node->resolve_props();
}
template <typename PredicateType>
node_t::prop_ptrs_t filter_props(node_t* node, PredicateType&& predicate)
{
return node->filter_props(std::forward<PredicateType>(predicate));
}
void clean_props(node_t* node)
{
node->clean_props();
}
void set_resolve_all_callback(node_t* node, node_t::resolve_callback_t&& resolver)
{
node->set_resolve_all_callback(std::move(resolver));
}
/* Restore the resolver callback to its default implementation
*
* See node_t::clear_resolve_all_callback() for details.
*/
void clear_resolve_all_callback(node_t* node)
{
node->clear_resolve_all_callback();
}
void set_graph_mutex_callback(node_t* node, node_t::graph_mutex_callback_t&& mutex)
{
node->set_graph_mutex_callback(std::move(mutex));
}
void clear_graph_mutex_callback(node_t* node)
{
node->clear_graph_mutex_callback();
}
void forward_edge_property(
node_t* dst_node, const size_t dst_port, property_base_t* incoming_prop)
{
dst_node->forward_edge_property(incoming_prop, dst_port);
}
void set_post_action_callback(node_t* node, node_t::action_handler_t&& post_handler)
{
node->set_post_action_callback(std::move(post_handler));
}
void send_action(
node_t* node, const res_source_info& port_info, action_info::sptr action)
{
node->receive_action(port_info, action);
}
void post_action(
node_t* node, const res_source_info& edge_info, action_info::sptr action)
{
node->post_action(edge_info, action);
}
bool check_topology(node_t* node,
const std::vector<size_t>& connected_inputs,
const std::vector<size_t>& connected_outputs)
{
return node->check_topology(connected_inputs, connected_outputs);
}
void shutdown(node_t* node)
{
node->shutdown();
}
};
}} /* 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