USRP Hardware Driver and USRP Manual Version: 3.15.0.0-MacPorts-Release
UHD and USRP Manual
 
Loading...
Searching...
No Matches
node_ctrl_base.hpp
Go to the documentation of this file.
1//
2// Copyright 2014-2016 Ettus Research LLC
3// Copyright 2018 Ettus Research, a National Instruments Company
4// Copyright 2019 Ettus Research, a National Instruments Brand
5//
6// SPDX-License-Identifier: GPL-3.0-or-later
7//
8
9#ifndef INCLUDED_LIBUHD_NODE_CTRL_BASE_HPP
10#define INCLUDED_LIBUHD_NODE_CTRL_BASE_HPP
11
14#include <uhd/utils/log.hpp>
16#include <stdint.h>
17#include <boost/enable_shared_from_this.hpp>
18#include <boost/function.hpp>
19#include <boost/shared_ptr.hpp>
20#include <boost/utility.hpp>
21#include <map>
22#include <set>
23
24namespace uhd { namespace usrp {
25// Forward declaration for friend clause
26class device3_impl;
27}} // namespace uhd::usrp
28
29namespace uhd { namespace rfnoc {
30
31#define UHD_RFNOC_BLOCK_TRACE() UHD_LOGGER_TRACE("RFNOC")
32
38 public boost::enable_shared_from_this<node_ctrl_base>
39{
40public:
41 /***********************************************************************
42 * Types
43 **********************************************************************/
44 typedef boost::shared_ptr<node_ctrl_base> sptr;
45 typedef boost::weak_ptr<node_ctrl_base> wptr;
46 typedef std::map<size_t, wptr> node_map_t;
47 typedef std::pair<size_t, wptr> node_map_pair_t;
48 typedef boost::function<void(void)> graph_update_cb_t;
49
50 /***********************************************************************
51 * Node control
52 **********************************************************************/
54 virtual std::string unique_id() const;
55
56 /***********************************************************************
57 * Connections
58 **********************************************************************/
61 virtual void clear();
62
71
74 void disconnect();
75
78 void disconnect_output_port(const size_t output_port);
79
82 void disconnect_input_port(const size_t input_port);
83
84 // TODO we need a more atomic connect procedure, this is too error-prone.
85
90 void set_downstream_port(const size_t this_port, const size_t remote_port);
91
96 size_t get_downstream_port(const size_t this_port);
97
102 void set_upstream_port(const size_t this_port, const size_t remote_port);
103
108 size_t get_upstream_port(const size_t this_port);
109
125 template <typename T>
126 UHD_INLINE std::vector<boost::shared_ptr<T> > find_downstream_node(
127 bool active_only = false)
128 {
129 return _find_child_node<T, true>(active_only);
130 }
131
134 template <typename T>
135 UHD_INLINE std::vector<boost::shared_ptr<T> > find_upstream_node(
136 bool active_only = false)
137 {
138 return _find_child_node<T, false>(active_only);
139 }
140
153 template <typename T, typename value_type>
155 boost::function<value_type(boost::shared_ptr<T> node, size_t port)> get_property,
156 value_type null_value,
157 const std::set<boost::shared_ptr<T> >& exclude_nodes =
158 std::set<boost::shared_ptr<T> >())
159 {
160 return _find_unique_property<T, value_type, true>(
161 get_property, null_value, exclude_nodes);
162 }
163
166 template <typename T, typename value_type>
168 boost::function<value_type(boost::shared_ptr<T> node, size_t port)> get_property,
169 value_type null_value,
170 const std::set<boost::shared_ptr<T> >& exclude_nodes =
171 std::set<boost::shared_ptr<T> >())
172 {
173 return _find_unique_property<T, value_type, false>(
174 get_property, null_value, exclude_nodes);
175 }
176
177protected:
178 /***********************************************************************
179 * Structors
180 **********************************************************************/
183 {
184 disconnect();
185 }
186
187 /***********************************************************************
188 * Protected members
189 **********************************************************************/
190
193
194 // TODO make these private
195
198
201
205
209
217 std::map<size_t, bool> _rx_streamer_active;
218
226 std::map<size_t, bool> _tx_streamer_active;
227
228 /***********************************************************************
229 * Connections
230 **********************************************************************/
238 node_ctrl_base::sptr downstream_node, size_t port);
239
246 virtual void _register_upstream_node(node_ctrl_base::sptr upstream_node, size_t port);
247
256 {
257 _graph_update_cb();
258 }
259
260private:
262
271 template <typename T, bool downstream>
272 std::vector<boost::shared_ptr<T> > _find_child_node(bool active_only = false);
273
282 template <typename T, typename value_type, bool downstream>
283 value_type _find_unique_property(
284 boost::function<value_type(boost::shared_ptr<T>, size_t)> get_property,
285 value_type NULL_VALUE,
286 const std::set<boost::shared_ptr<T> >& exclude_nodes);
287
288 void set_graph_update_cb(graph_update_cb_t graph_update_cb)
289 {
290 _graph_update_cb = graph_update_cb;
291 }
292
295 std::map<size_t, size_t> _upstream_ports;
296
299 std::map<size_t, size_t> _downstream_ports;
300
301 graph_update_cb_t _graph_update_cb;
302
303}; /* class node_ctrl_base */
304
305}} /* namespace uhd::rfnoc */
306
308
309#endif /* INCLUDED_LIBUHD_NODE_CTRL_BASE_HPP */
Definition device_addr.hpp:39
Definition node_ctrl_base.hpp:39
node_map_t _downstream_nodes
List of downstream nodes.
Definition node_ctrl_base.hpp:200
UHD_INLINE value_type find_upstream_unique_property(boost::function< value_type(boost::shared_ptr< T > node, size_t port)> get_property, value_type null_value, const std::set< boost::shared_ptr< T > > &exclude_nodes=std::set< boost::shared_ptr< T > >())
Definition node_ctrl_base.hpp:167
size_t get_upstream_port(const size_t this_port)
uhd::device_addr_t _args
Stores default arguments.
Definition node_ctrl_base.hpp:192
virtual std::string unique_id() const
Returns a unique string that identifies this block.
boost::weak_ptr< node_ctrl_base > wptr
Definition node_ctrl_base.hpp:45
size_t _num_output_ports
Definition node_ctrl_base.hpp:208
void disconnect_input_port(const size_t input_port)
virtual ~node_ctrl_base()
Definition node_ctrl_base.hpp:182
void update_graph()
Definition node_ctrl_base.hpp:255
boost::function< void(void)> graph_update_cb_t
Definition node_ctrl_base.hpp:48
virtual void _register_downstream_node(node_ctrl_base::sptr downstream_node, size_t port)
std::map< size_t, wptr > node_map_t
Definition node_ctrl_base.hpp:46
virtual void _register_upstream_node(node_ctrl_base::sptr upstream_node, size_t port)
std::map< size_t, bool > _tx_streamer_active
Definition node_ctrl_base.hpp:226
UHD_INLINE std::vector< boost::shared_ptr< T > > find_downstream_node(bool active_only=false)
Definition node_ctrl_base.hpp:126
UHD_INLINE std::vector< boost::shared_ptr< T > > find_upstream_node(bool active_only=false)
Definition node_ctrl_base.hpp:135
size_t get_downstream_port(const size_t this_port)
node_map_t list_upstream_nodes()
Definition node_ctrl_base.hpp:67
void set_downstream_port(const size_t this_port, const size_t remote_port)
node_map_t _upstream_nodes
List of upstream nodes.
Definition node_ctrl_base.hpp:197
std::pair< size_t, wptr > node_map_pair_t
Definition node_ctrl_base.hpp:47
UHD_INLINE value_type find_downstream_unique_property(boost::function< value_type(boost::shared_ptr< T > node, size_t port)> get_property, value_type null_value, const std::set< boost::shared_ptr< T > > &exclude_nodes=std::set< boost::shared_ptr< T > >())
Definition node_ctrl_base.hpp:154
void disconnect_output_port(const size_t output_port)
boost::shared_ptr< node_ctrl_base > sptr
Definition node_ctrl_base.hpp:44
std::map< size_t, bool > _rx_streamer_active
Definition node_ctrl_base.hpp:217
node_map_t list_downstream_nodes()
Definition node_ctrl_base.hpp:63
size_t _num_input_ports
Definition node_ctrl_base.hpp:204
void set_upstream_port(const size_t this_port, const size_t remote_port)
friend class uhd::usrp::device3_impl
Definition node_ctrl_base.hpp:261
node_ctrl_base(void)
Definition node_ctrl_base.hpp:181
#define UHD_INLINE
Definition config.h:53
#define UHD_RFNOC_API
Definition config.hpp:117
Definition build_info.hpp:13
boost::noncopyable noncopyable
Definition noncopyable.hpp:46