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 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.
28 #include <gr_block_detail.h>
31 static long s_next_id = 0;
32 static long s_ncurrently_allocated = 0;
35 gr_block_ncurrently_allocated ()
37 return s_ncurrently_allocated;
40 gr_block::gr_block (const std::string &name,
41 gr_io_signature_sptr input_signature,
42 gr_io_signature_sptr output_signature)
44 d_input_signature (input_signature),
45 d_output_signature (output_signature),
46 d_output_multiple (1),
47 d_relative_rate (1.0),
48 d_unique_id (s_next_id++),
52 s_ncurrently_allocated++;
55 gr_block::~gr_block ()
57 s_ncurrently_allocated--;
60 // stub implementation: 1:1
63 gr_block::forecast (int noutput_items, gr_vector_int &ninput_items_required)
65 unsigned ninputs = ninput_items_required.size ();
66 for (unsigned i = 0; i < ninputs; i++)
67 ninput_items_required[i] = noutput_items;
70 // default implementation
73 gr_block::check_topology (int ninputs, int noutputs)
91 gr_block::set_output_multiple (int multiple)
94 throw std::invalid_argument ("gr_block::set_output_multiple");
96 d_output_multiple = multiple;
100 gr_block::set_relative_rate (double relative_rate)
102 if (relative_rate < 0.0)
103 throw std::invalid_argument ("gr_block::set_relative_rate");
105 d_relative_rate = relative_rate;
110 gr_block::consume (int which_input, int how_many_items)
112 d_detail->consume (which_input, how_many_items);
116 gr_block::consume_each (int how_many_items)
118 d_detail->consume_each (how_many_items);
122 gr_block::fixed_rate_ninput_to_noutput(int ninput)
124 throw std::runtime_error("Unimplemented");
128 gr_block::fixed_rate_noutput_to_ninput(int noutput)
130 throw std::runtime_error("Unimplemented");