3 * Copyright 2006,2007,2008,2009 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
22 #ifndef INCLUDED_GR_HIER_BLOCK2_H
23 #define INCLUDED_GR_HIER_BLOCK2_H
25 #include <gr_basic_block.h>
28 * \brief public constructor for gr_hier_block2
31 gr_hier_block2_sptr gr_make_hier_block2(const std::string &name,
32 gr_io_signature_sptr input_signature,
33 gr_io_signature_sptr output_signature);
35 class gr_hier_block2_detail;
38 * \brief Hierarchical container class for gr_block's and gr_hier_block2's
39 * \ingroup container_blk
43 class gr_hier_block2 : public gr_basic_block
46 friend class gr_hier_block2_detail;
47 friend gr_hier_block2_sptr gr_make_hier_block2(const std::string &name,
48 gr_io_signature_sptr input_signature,
49 gr_io_signature_sptr output_signature);
52 * \brief Private implementation details of gr_hier_block2
54 gr_hier_block2_detail *d_detail;
57 gr_hier_block2(const std::string &name,
58 gr_io_signature_sptr input_signature,
59 gr_io_signature_sptr output_signature);
62 virtual ~gr_hier_block2();
65 * \brief typedef for object returned from self().
67 * This type is only guaranteed to be passable to connect and disconnect.
68 * No other assumptions should be made about it.
70 typedef gr_basic_block_sptr opaque_self;
73 * \brief Return an object, representing the current block, which can be passed to connect.
75 * The returned object may only be used as an argument to connect or disconnect.
76 * Any other use of self() results in unspecified (erroneous) behavior.
81 * \brief Add a stand-alone (possibly hierarchical) block to internal graph
83 * This adds a gr-block or hierarchical block to the internal graph
84 * without wiring it to anything else.
86 void connect(gr_basic_block_sptr block);
89 * \brief Add gr-blocks or hierarchical blocks to internal graph and wire together
91 * This adds (if not done earlier by another connect) a pair of gr-blocks or
92 * hierarchical blocks to the internal flowgraph, and wires the specified output
93 * port to the specified input port.
95 void connect(gr_basic_block_sptr src, int src_port,
96 gr_basic_block_sptr dst, int dst_port);
99 * \brief Remove a gr-block or hierarchical block from the internal flowgraph.
101 * This removes a gr-block or hierarchical block from the internal flowgraph,
102 * disconnecting it from other blocks as needed.
105 void disconnect(gr_basic_block_sptr block);
108 * \brief Disconnect a pair of gr-blocks or hierarchical blocks in internal
111 * This disconnects the specified input port from the specified output port
112 * of a pair of gr-blocks or hierarchical blocks.
114 void disconnect(gr_basic_block_sptr src, int src_port,
115 gr_basic_block_sptr dst, int dst_port);
118 * \brief Disconnect all connections in the internal flowgraph.
120 * This call removes all output port to input port connections in the internal
123 void disconnect_all();
126 * Lock a flowgraph in preparation for reconfiguration. When an equal
127 * number of calls to lock() and unlock() have occurred, the flowgraph
128 * will be reconfigured.
130 * N.B. lock() and unlock() may not be called from a flowgraph thread
131 * (E.g., gr_block::work method) or deadlock will occur when
132 * reconfiguration happens.
137 * Unlock a flowgraph in preparation for reconfiguration. When an equal
138 * number of calls to lock() and unlock() have occurred, the flowgraph
139 * will be reconfigured.
141 * N.B. lock() and unlock() may not be called from a flowgraph thread
142 * (E.g., gr_block::work method) or deadlock will occur when
143 * reconfiguration happens.
145 virtual void unlock();
147 // This is a public method for ease of code organization, but should be
148 // ignored by the user.
149 gr_flat_flowgraph_sptr flatten() const;
152 inline gr_hier_block2_sptr cast_to_hier_block2_sptr(gr_basic_block_sptr block) {
153 return boost::dynamic_pointer_cast<gr_hier_block2, gr_basic_block>(block);
156 #endif /* INCLUDED_GR_HIER_BLOCK2_H */