d566b367465908aec6525ed2814dadf303221c94
[debian/gnuradio] / gnuradio-core / src / lib / filter / gri_fir_filter_with_buffer_XXX.h.t
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2010 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 /*
24  * WARNING: This file is automatically generated by generate_gri_fir_XXX.py
25  * Any changes made to this file will be overwritten.
26  */
27
28
29 #ifndef @GUARD_NAME@
30 #define @GUARD_NAME@
31
32 #include <vector>
33 #include <gr_types.h>
34 #include <gr_reverse.h>
35 #include <string.h>
36 #include <cstdio>
37
38 /*!
39  * \brief FIR with internal buffer for @I_TYPE@ input, 
40           @O_TYPE@ output and @TAP_TYPE@ taps
41  * \ingroup filter
42  * 
43  */
44
45 class @NAME@ {
46
47 protected:
48   std::vector<@TAP_TYPE@>       d_taps;         // reversed taps
49   @I_TYPE@                     *d_buffer;
50   unsigned int                  d_idx;
51
52 public:
53
54   // CONSTRUCTORS
55
56   /*!
57    * \brief construct new FIR with given taps.
58    *
59    * Note that taps must be in forward order, e.g., coefficient 0 is
60    * stored in new_taps[0], coefficient 1 is stored in
61    * new_taps[1], etc.
62    */
63   @NAME@ (const std::vector<@TAP_TYPE@> &taps);
64
65   ~@NAME@ ();
66
67   // MANIPULATORS
68
69   /*!
70    * \brief compute a single output value.
71    *
72    * \p input must have ntaps() valid entries.
73    * input[0] .. input[ntaps() - 1] are referenced to compute the output value.
74    *
75    * \returns the filtered input value.
76    */
77   @O_TYPE@ filter (@I_TYPE@ input);
78
79   /*!
80    * \brief compute an array of N output values.
81    *
82    * \p input must have (n - 1 + ntaps()) valid entries.
83    * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values.
84    */
85   void filterN (@O_TYPE@ output[], const @I_TYPE@ input[],
86                 unsigned long n);
87
88   /*!
89    * \brief compute an array of N output values, decimating the input
90    *
91    * \p input must have (decimate * (n - 1) + ntaps()) valid entries.
92    * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to 
93    * compute the output values.
94    */
95   void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[],
96                    unsigned long n, unsigned decimate);
97
98   /*!
99    * \brief install \p new_taps as the current taps.
100    */
101   void set_taps (const std::vector<@TAP_TYPE@> &taps);
102
103   // ACCESSORS
104
105   /*!
106    * \return number of taps in filter.
107    */
108   unsigned ntaps () const { return d_taps.size (); }
109
110   /*!
111    * \return current taps
112    */
113   const std::vector<@TAP_TYPE@> get_taps () const
114   {
115     return gr_reverse(d_taps);
116   }
117 };
118
119 #endif /* @GUARD_NAME@ */