3 * Copyright 2004 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 detail.
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.
23 #ifndef INCLUDED_GR_BLOCK_DETAIL_H
24 #define INCLUDED_GR_BLOCK_DETAIL_H
26 #include <gr_runtime_types.h>
27 #include <gr_tpb_detail.h>
31 * \brief Implementation details to support the signal processing abstraction
34 * This class contains implementation detail that should be "out of sight"
35 * of almost all users of GNU Radio. This decoupling also means that
36 * we can make changes to the guts without having to recompile everything.
38 class gr_block_detail {
42 int ninputs () const { return d_ninputs; }
43 int noutputs () const { return d_noutputs; }
44 bool sink_p () const { return d_noutputs == 0; }
45 bool source_p () const { return d_ninputs == 0; }
47 void set_done (bool done);
48 bool done () const { return d_done; }
50 void set_input (unsigned int which, gr_buffer_reader_sptr reader);
51 gr_buffer_reader_sptr input (unsigned int which)
53 if (which >= d_ninputs)
54 throw std::invalid_argument ("gr_block_detail::input");
55 return d_input[which];
58 void set_output (unsigned int which, gr_buffer_sptr buffer);
59 gr_buffer_sptr output (unsigned int which)
61 if (which >= d_noutputs)
62 throw std::invalid_argument ("gr_block_detail::output");
63 return d_output[which];
67 * \brief Tell the scheduler \p how_many_items of input stream \p which_input were consumed.
69 void consume (int which_input, int how_many_items);
72 * \brief Tell the scheduler \p how_many_items were consumed on each input stream.
74 void consume_each (int how_many_items);
77 * \brief Tell the scheduler \p how_many_items were produced on each output stream.
79 void produce_each (int how_many_items);
82 gr_tpb_detail d_tpb; // used by thread-per-block scheduler
84 // ----------------------------------------------------------------------------
87 unsigned int d_ninputs;
88 unsigned int d_noutputs;
89 std::vector<gr_buffer_reader_sptr> d_input;
90 std::vector<gr_buffer_sptr> d_output;
94 gr_block_detail (unsigned int ninputs, unsigned int noutputs);
96 friend class gr_tpb_detail;
98 friend gr_block_detail_sptr
99 gr_make_block_detail (unsigned int ninputs, unsigned int noutputs);
103 gr_make_block_detail (unsigned int ninputs, unsigned int noutputs);
106 gr_block_detail_ncurrently_allocated ();
108 #endif /* INCLUDED_GR_BLOCK_DETAIL_H */