3 # Copyright 2003 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 2, 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')
52 * WARNING: This file is automatically generated by
53 * generate_gr_fir_util.py.
55 * Any changes made to this file will be overwritten.
58 #ifndef INCLUDED_GR_FIR_UTIL_H
59 #define INCLUDED_GR_FIR_UTIL_H
62 * \\brief routines to create gr_fir_XXX's
64 * This class handles selecting the fastest version of the finite
65 * implulse response filter available for your platform. This
66 * interface should be used by the rest of the system for creating
69 * The trailing suffix has the form _IOT where I codes the input type,
70 * O codes the output type, and T codes the tap type.
71 * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex),
79 for sig in fir_signatures:
80 out.write ('class gr_fir_%s;\n' % sig);
82 out.write ('\n// structures returned by get_gr_fir_XXX_info methods\n\n')
84 for sig in fir_signatures:
85 make_info_struct (out, sig)
90 // create a fast version of gr_fir_XXX.
94 for sig in fir_signatures:
95 make_create (out, sig)
98 // Get information about all gr_fir_XXX implementations.
99 // This is useful for benchmarking, testing, etc without having to
100 // know a priori what's linked into this image
102 // The caller must pass in a valid pointer to a vector.
103 // The vector will be filled with structs describing the
104 // available implementations.
108 for sig in fir_signatures:
114 #endif /* INCLUDED_GR_FIR_UTIL_H */
119 # ----------------------------------------------------------------
121 def make_constructor_cc (out, sig):
125 gr_fir_util::create_gr_fir_%s (const std::vector<%s> &taps)
127 return gr_fir_sysconfig_singleton()->create_gr_fir_%s (taps);
129 ''' % (sig, sig, tap_type (sig), sig))
132 def make_info_cc (out, sig):
136 gr_fir_util::get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info)
138 gr_fir_sysconfig_singleton()->get_gr_fir_%s_info (info);
140 ''' % (sig, sig, sig))
143 def make_gr_fir_util_cc ():
144 out = open_and_log_name ('gr_fir_util.cc', 'w')
145 out.write (copyright)
151 #include <gr_fir_util.h>
152 #include <gr_fir_sysconfig.h>
155 // There's no problem that can't be solved by the addition of
156 // another layer of indirection...
159 // --- constructors ---
163 for sig in fir_signatures:
164 make_constructor_cc (out, sig)
167 // --- info gatherers ---
171 for sig in fir_signatures:
172 make_info_cc (out, sig)
177 # ----------------------------------------------------------------
180 make_gr_fir_util_h ()
181 make_gr_fir_util_cc ()
183 if __name__ == '__main__':