Houston, we have a trunk.
[debian/gnuradio] / gr-error-correcting-codes / src / lib / libecc / decoder.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 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 2, 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., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef INCLUDED_DECODER_H
24 #define INCLUDED_DECODER_H
25
26 #include "code_types.h"
27
28 // the 'decoder' class is a virtual class upon which all decoder types
29 // can be built.
30
31 class decoder
32 {
33 public:
34   decoder () {};
35   virtual ~decoder () {};
36
37   virtual size_t compute_n_input_metrics (size_t n_output_bits) = 0;
38   virtual size_t compute_n_output_bits (size_t n_input_metrics) = 0;
39   virtual size_t decode (const char** in_buf,
40                          char** out_buf,
41                          size_t n_bits_to_output);
42   virtual size_t decode (const char** in_buf,
43                          size_t n_metrics_to_input,
44                          char** out_buf);
45
46 protected:
47   virtual void decode_private (const char** in_buf, char** out_buf) = 0;
48   virtual char get_next_input (const char** in_buf, size_t code_input_n) = 0;
49   virtual void output_bit (char t_out_bit, char** out_buf,
50                            size_t t_output_stream) = 0;
51
52   size_t d_block_size_bits, d_n_code_inputs, d_n_code_outputs;
53   size_t d_n_dec_bits;
54   size_t d_in_buf_ndx, d_out_buf_ndx;
55   size_t d_in_bit_shift, d_out_bit_shift;
56   size_t d_n_input_metrics_left, d_n_output_bits_left;
57 };
58
59 #endif /* INCLUDED_DECODER_H */