3 # Copyright 2003,2009 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.
23 from generate_utils import *
25 def make_info_struct (out, sig):
28 struct gr_fir_%s_info {
29 const char *name; // implementation name, e.g., "generic", "SSE", "3DNow!"
30 gr_fir_%s *(*create)(const std::vector<%s> &taps);
32 ''' % (sig, sig, tap_type(sig)))
34 def make_create (out, sig):
35 out.write (''' static gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps);
36 ''' % (sig, sig, tap_type (sig)))
38 def make_info (out, sig):
39 out.write (''' static void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info);
43 # ----------------------------------------------------------------
45 def make_gr_fir_util_h ():
46 out = open_and_log_name ('gr_fir_util.h', 'w')
54 * WARNING: This file is automatically generated by
55 * generate_gr_fir_util.py.
57 * Any changes made to this file will be overwritten.
60 #ifndef INCLUDED_GR_FIR_UTIL_H
61 #define INCLUDED_GR_FIR_UTIL_H
64 * \\brief routines to create gr_fir_XXX's
66 * This class handles selecting the fastest version of the finite
67 * implulse response filter available for your platform. This
68 * interface should be used by the rest of the system for creating
71 * The trailing suffix has the form _IOT where I codes the input type,
72 * O codes the output type, and T codes the tap type.
73 * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex),
81 for sig in fir_signatures:
82 out.write ('class gr_fir_%s;\n' % sig);
84 out.write ('\n// structures returned by get_gr_fir_XXX_info methods\n\n')
86 for sig in fir_signatures:
87 make_info_struct (out, sig)
92 // create a fast version of gr_fir_XXX.
96 for sig in fir_signatures:
97 make_create (out, sig)
100 // Get information about all gr_fir_XXX implementations.
101 // This is useful for benchmarking, testing, etc without having to
102 // know a priori what's linked into this image
104 // The caller must pass in a valid pointer to a vector.
105 // The vector will be filled with structs describing the
106 // available implementations.
110 for sig in fir_signatures:
116 #endif /* INCLUDED_GR_FIR_UTIL_H */
121 # ----------------------------------------------------------------
123 def make_constructor_cc (out, sig):
127 gr_fir_util::create_gr_fir_%s (const std::vector<%s> &taps)
129 return gr_fir_sysconfig_singleton()->create_gr_fir_%s (taps);
131 ''' % (sig, sig, tap_type (sig), sig))
134 def make_info_cc (out, sig):
138 gr_fir_util::get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info)
140 gr_fir_sysconfig_singleton()->get_gr_fir_%s_info (info);
142 ''' % (sig, sig, sig))
145 def make_gr_fir_util_cc ():
146 out = open_and_log_name ('gr_fir_util.cc', 'w')
149 out.write (copyright)
155 #include <gr_fir_util.h>
156 #include <gr_fir_sysconfig.h>
159 // There's no problem that can't be solved by the addition of
160 // another layer of indirection...
163 // --- constructors ---
167 for sig in fir_signatures:
168 make_constructor_cc (out, sig)
171 // --- info gatherers ---
175 for sig in fir_signatures:
176 make_info_cc (out, sig)
181 # ----------------------------------------------------------------
184 make_gr_fir_util_h ()
185 make_gr_fir_util_cc ()
187 if __name__ == '__main__':