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>
32 gr_block::gr_block (const std::string &name,
33 gr_io_signature_sptr input_signature,
34 gr_io_signature_sptr output_signature)
35 : gr_basic_block(name, input_signature, output_signature),
36 d_output_multiple (1),
37 d_relative_rate (1.0),
43 gr_block::~gr_block ()
47 // stub implementation: 1:1
50 gr_block::forecast (int noutput_items, gr_vector_int &ninput_items_required)
52 unsigned ninputs = ninput_items_required.size ();
53 for (unsigned i = 0; i < ninputs; i++)
54 ninput_items_required[i] = noutput_items + history() - 1;
57 // default implementation
72 gr_block::set_output_multiple (int multiple)
75 throw std::invalid_argument ("gr_block::set_output_multiple");
77 d_output_multiple = multiple;
81 gr_block::set_relative_rate (double relative_rate)
83 if (relative_rate < 0.0)
84 throw std::invalid_argument ("gr_block::set_relative_rate");
86 d_relative_rate = relative_rate;
91 gr_block::consume (int which_input, int how_many_items)
93 d_detail->consume (which_input, how_many_items);
97 gr_block::consume_each (int how_many_items)
99 d_detail->consume_each (how_many_items);
103 gr_block::fixed_rate_ninput_to_noutput(int ninput)
105 throw std::runtime_error("Unimplemented");
109 gr_block::fixed_rate_noutput_to_ninput(int noutput)
111 throw std::runtime_error("Unimplemented");
115 operator << (std::ostream& os, const gr_block *m)
117 os << "<gr_block " << m->name() << " (" << m->unique_id() << ")>";