1 /* -*- c++ -*- */
2 /*
3  * Copyright 2013-2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
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)
10  * any later version.
11  *
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.
16  *
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.
21  */
22 
23 #ifndef INCLUDED_FEC_ENCODER_H
24 #define INCLUDED_FEC_ENCODER_H
25 
26 #include <gnuradio/block.h>
27 #include <gnuradio/fec/api.h>
28 #include <gnuradio/fec/generic_encoder.h>
29 #include <boost/shared_ptr.hpp>
30 
31 namespace gr {
32 namespace fec {
33 
34 /*!
35  * \brief Creates the encoder block for use in GNU Radio
36  * flowgraphs from a given FECAPI object derived from the
37  * generic_encoder class.
38  * \ingroup error_coding_blk
39  *
40  * \details
41  *
42  * Generally, we would use the fec.extended_encoder Python
43  * implementation to instantiate this. The extended_encoder wraps
44  * up a few more details, like taking care of puncturing as well
45  * as the encoder itself.
46  */
47 class FEC_API encoder : virtual public block
48 {
49 public:
50     typedef boost::shared_ptr<encoder> sptr;
51 
52     /*!
53      * Build the FEC encoder block from an FECAPI encoder object.
54      *
55      * \param my_encoder An FECAPI encoder object child of the generic_encoder class.
56      * \param input_item_size size of a block of data for the encoder.
57      * \param output_item_size size of a block of data the encoder will produce.
58      */
59     static sptr make(generic_encoder::sptr my_encoder,
60                      size_t input_item_size,
61                      size_t output_item_size);
62 
63     virtual int general_work(int noutput_items,
64                              gr_vector_int& ninput_items,
65                              gr_vector_const_void_star& input_items,
66                              gr_vector_void_star& output_items) = 0;
67     virtual int fixed_rate_ninput_to_noutput(int ninput) = 0;
68     virtual int fixed_rate_noutput_to_ninput(int noutput) = 0;
69     virtual void forecast(int noutput_items, gr_vector_int& ninput_items_required) = 0;
70 };
71 
72 } /* namespace fec */
73 } /* namespace gr */
74 
75 #endif /* INCLUDED_FEC_ENCODER_H */
76